[webadm@localhost wiki]$ cat Tcard3.php <?php /* $h=1347; $w=2031; $dw=$w/7; $dh=$h/7; $A=來源影像, 寬$wa 高$ha $B=目的影像, 寬$wb 高$hb */ $h=1347; $w=2031; $dw=$w/9; $dh=$h/9;
$dw0=$dw/7; $dh0=$dh/7; $dw1=$dw/9; $dh1=$dh/9;
require_once( 'includes/WebStart.php' ); define( 'MW_NO_SETUP', 1 ); define( 'MW_NO_OUTPUT_COMPRESSION', 1 ); require_once( 'includes/WebStart.php' ); wfProfileIn( 'thumb.php' ); wfProfileIn( 'thumb.php-start' ); require_once( "includes/GlobalFunctions.php" ); require_once( "includes/ImageFunctions.php" );
$wgTrivialMimeDetection = true; //don't use fancy mime detection, just check the file extension for jpg/gif/png. require_once( "includes/StreamFile.php" ); require_once( "includes/AutoLoader.php" ); $csv=fopen('digit3.csv','r'); $c=0; $array=fgetcsv($csv,100,":") ; $bgR=$array[1]; $bgG=$array[2]; $bgB=$array[3];
while ($array=fgetcsv($csv,100,":") ) { $fileName[$c]="$array[1]"; $hash = md5( $fileName[$c] ); $dest[$c] = 'http://insecta.idv.tw/wiki/images/' . $hash{0} . '/' . substr( $hash, 0, 2 ) . '/' . urlencode($fileName[$c]) ; $c++; } fclose($csv);
$csv=fopen('imageV3.txt','r'); $c=0; while ($array=fgetcsv($csv,250,"|") ) { $fileName[$c]="$array[1]"; //檔名 $Bstr4[$c]="$array[6]"; //地點 $Bstr3[$c]="$array[2]$array[3]$array[4]$array[5]"; //年,月,日,縣 $Bstr2[$c]="$array[10] $array[9] $array[7]"; // 目,科,種名 $Bstr1[$c]="$array[8]"; // 學名 $hash = md5( $fileName[$c] ); $Bdest[$c] = 'http://insecta.idv.tw/wiki/images/' . $hash{0} . '/' . substr( $hash, 0, 2 ) . '/' . urlencode($fileName[$c]) ; $c++; } fclose($csv);
$num=$_GET['num']; $kind=$_GET['kind'];
$xx=($num-1)*4+$kind;
$ss="num=$num , kind=$kind , xx=$xx <br>\n"; $src_file=$Bdest[$xx-1];
header("Content-type:image/jpeg"); $A=ImageCreateFromJPEG($src_file);
switch($kind){ case 1: $ccc=$dest[2]; break; //SpadeB.gif case 2: $ccc=$dest[1]; break; //HeartB.gif case 3: $ccc=$dest[3]; break; //DiamondB.gif case 4: $ccc=$dest[0] ;break; //ClubB.gif default: $ccc=$dest[2];; } $C1=ImageCreateFromGif($ccc); switch($kind){ case 1: $ccc=$dest[2+60]; break; //SpadeB.gif case 2: $ccc=$dest[1+60]; break; //HeartB.gif case 3: $ccc=$dest[3+60]; break; //DiamondB.gif case 4: $ccc=$dest[0+60] ;break; //ClubB.gif default: $ccc=$dest[2];; } $C2=ImageCreateFromGif($ccc);
if ($kind==1 || $kind==4) { $D1=ImageCreateFromGif($dest[7+$num]); $D2=ImageCreateFromGif($dest[7+13+$num]); } if ($kind==2 || $kind==3) { $D1=ImageCreateFromGif($dest[7+$num+26]); $D2=ImageCreateFromGif($dest[7+13+$num+26]); } if ($xx==53) { $D1=ImageCreateFromGif($dest[4]); $D2=ImageCreateFromGif($dest[5]); } if ($xx==54) { $D1=ImageCreateFromGif($dest[6]); $D2=ImageCreateFromGif($dest[7]); }
$B=ImageCreateTrueColor($w,$h); $a=ImageColorAllocate($B,$bgR,$bgG,$bgB); $b=ImageColorAllocate($B,45,0,255); $b2=ImageColorAllocate($B,104,0,195); $b2=ImageColorAllocate($B,120,205,0);
$e=ImageColorAllocate($B,200,40,20); $x1=1; $y1=1; $x2=$w-1; $y2=$h-1; $wa=ImageSX($A); $ha=ImageSY($A); $ra=$wa/$ha;
$wb=$w-4*$dw; $hb=$wb/$ra; //int imagecopyresized(int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH); ImageCopyResized($B,$A,($w-$wb)/2,($h-$hb)/2,0,0,$wb,$hb,$wa,$ha); imagefill($B,$x1+10,$y1+10,$a);
if ($kind<5) { ImageCopyResized($B,$D2,$w-$dw-2*$dw0,0+2*$dh0,0,0,$dw,$dh,ImageSX($D1),ImageSY($D1)); ImageCopyResized($B,$C2,$w-$dw-8*$dw0+$dw/6,$dh-4*$dh0,0,0,$dw*2/3,$dh*2/3,ImageSX($C1),ImageSY($C1)); ImageCopyResized($B,$D1,2*$dw0,$h-$dh-2*$dh0,0,0,$dw,$dh,ImageSX($D2),ImageSY($D2)); ImageCopyResized($B,$C1,9*$dw0,$h-$dh-1*$dh0,0,0,$dw*2/3,$dh*2/3,ImageSX($C2),ImageSY($C2)); } else { ImageCopyResized($B,$D1,0+1.8*$dw0,0+1.5*$dh0,0,0,$dw,2*$dh,ImageSX($D1),ImageSY($D1)); ImageCopyResized($B,$D2,$w-$dw-1.5*$dw0,$h-2*$dh-1.8*$dh0,0,0,$dw,2*$dh,ImageSX($D2),ImageSY($D2)); }
ImageRectangle($B, $x1,$y1,$x2,$y2, $e);
$font = "/usr/share/fonts/cjkunifonts-ukai/ukai.ttf";
$sfile=$Bstr1[$xx-1]; //array imagettftext ( resource image, int size, int angle, int x, int y, int color, string fontfile, string text ) ImageTTFtext($B, 40, 90 , ($w+$wb)/2+0.2*$dw , ($h+$hb)/2-0.1*$dh, $b2, $font, $sfile);
$sfile=$Bstr2[$xx-1]; ImageTTFtext($B, 40, 90 , ($w+$wb)/2+0.5*$dw , ($h+$hb)/2-0.1*$dh, $b, $font, $sfile);
$sfile=$Bstr3[$xx-1]; ImageTTFtext($B, 40, 90 , ($w+$wb)/2+0.8*$dw , ($h+$hb)/2-0.1*$dh, $b, $font, $sfile);
$sfile=$Bstr4[$xx-1]; ImageTTFtext($B, 40, 90 , ($w+$wb)/2+1.1*$dw , ($h+$hb)/2-0.1*$dh, $b, $font, $sfile); $sfile="台灣昆蟲維基館"; ImageTTFtext($B, 50, 90 , ($w-$wb)/2-0.3*$dw , 3*$h/4, $e, $font, $sfile); ImageJPEG($B); ImageDestroy($D1); ImageDestroy($D2); ImageDestroy($C1); ImageDestroy($C2); ImageDestroy($A); ImageDestroy($B); ?> |