note 53214 deleted from function.imagecopyresampled by cmb
| From: | cmb@php.net | Date: | Sun, 19 May 2019 16:09:38 +0000 |
| Subject: | note 53214 deleted from function.imagecopyresampled by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211075@lists.php.net to get a copy of this message | ||
Note Submitter: Pie pie
----
Confirming on what fluffle said, and to say his code will also crop and resize an image what is
smaller than 100x100 pixels if you want. This is important because it means your images no matter
how you decide to rezise them, will maintain their aspect ratios and with a minimum amount of image
loss.
//Get file type
$mime = $orig_image_mimetype;
$type = substr($mime, strpos($mime,'/')+1);
switch($type) {
case 'jpeg':
case 'pjpeg':
$big = imagecreatefromjpeg($file);
break;
case 'png':
case 'x-png':
$big = imagecreatefrompng($file);
break;
case 'gif':
$big = imagecreatefromgif($file);
break;
default:
return FALSE;
break;
}
The above code is what I use to support multiple file type resizing. I then use the same thing again
when it's time to output the image using $result = imagejpeg($thumb,'',80),
imagepng($thumb), and imagegif($thumb).