* index.php
'image/jpeg'
// 'mime' => 'image/png'
$a = explode('/', $info['mime']);
$type = array_pop($a);
unset($a);
$dstPath = "tmp.".$type;
call_user_func("image".$type, $dst, $dstPath);
// == 缩略图生成完了 ==
$dstW = $thumbWidth;
$dstH = $thumbHeight;
list($dstW, $dstH) = getimagesize($dstPath);
$src = imagecreatefromstring($dataSrc);
imagecopymerge($dst, $src,
$dstW - $srcW, $dstH - $srcH,
0, 0, $srcW, $srcH, 100);
call_user_func("image".$type, $dst, "out.".$type);
imagedestroy($src);
imagedestroy($dst);
* autoload.php
* ./lib/Image.php
0) { $width = $bigWidth * $per; $height = $bigHight * $per; } // 创建缩略图画板 $block = imagecreatetruecolor($width, $height); // 启用混色模式 imagealphablending($block, false); // 保存PNG alpha通道信息 imagesavealpha($block, true); // 创建原图画板 $bigImg = imagecreatefromstring($imagedata); // 缩放 imagecopyresampled($block, $bigImg, 0, 0, 0, 0, $width, $height, $bigWidth, $bigHight); // 生成临时文件名 $tmpFilename = tempnam(sys_get_temp_dir(), 'image_'); // 保存 switch ($bigType) { case 1: imagegif($block, $tmpFilename); break; case 2: imagejpeg($block, $tmpFilename); break; case 3: imagepng($block, $tmpFilename); break; } // 销毁 imagedestroy($block); $image = file_get_contents($tmpFilename); unlink($tmpFilename); return $image; } }
把国旗图片覆盖到目的图片右下角



