I have a php thumbnail function. How it works you can check below:
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;
}
Please check images below (how it works):
Question: How can I get this image as a result (This thumb is from photoshop)?