我有一個php縮略圖功能。它是如何運作的,你可以檢查以下內容:正方形縮略圖前進
public static function makeThumb($source, $destination, $thumb_width){
$size = getimagesize($source);
$width = $size[0];
$height = $size[1];
$x = 0;
$y = 0;
$status = false;
if ($width > $height) {
$x = ceil(($width - $height)/2);
$width = $height;
} else if ($height > $width) {
$y = ceil(($height - $width)/2);
$height = $width;
}
$new_image = imagecreatetruecolor($thumb_width,$thumb_width) or die ('Cannot Initialize new GD image stream');
$extension = self::get_file_extension($source);
if ($extension == 'jpg' || $extension == 'jpeg')
$image = imagecreatefromjpeg($source);
if ($extension == 'gif')
$image = imagecreatefromgif($source);
if ($extension == 'png')
$image = imagecreatefrompng($source);
imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height);
if ($extension == 'jpg' || $extension == 'jpeg')
$status = @imagejpeg($new_image, $destination);
if ($extension == 'gif')
$status = @imagegif($new_image, $destination);
if ($extension == 'png')
$status = @imagepng($new_image, $destination);
imagedestroy($image);
return $status;
}
請檢查下面的圖像(它是如何工作):
問:我怎樣才能得到這個圖像的結果(這拇指來自photoshop)?
使用PHP [imagick庫](http://php.net/manual/en/class.imagick.php),用於多個選項。 – Rikesh
我知道,但需要GD解決方案。謝謝。 – user889349