我有一个 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)?