Vinod Kumar Vinod Kumar - 1 year ago 86
PHP Question

How can I save thumbnails in this script?

This is the script I am using to resize images in my site. But I don't know how to add a feature to save thumbnails of that images.
If I can save the thumb, it will be possible to use that thumb later without using this script again and again.

$neww = 65;
$newh = 87;
list(, , $type,)=getimagesize($file);

if($type==1) {
} //$funco='imagegif';}

if($type==2) {
} //$funco='imagejpeg';}

if($type==3) {
} //$funco='imagepng';}

if($type) {
$im1 = $funci($file);
imagecopyresized($im2, $im1, 0,0,0,0,$neww,$newh, imagesx($im1), imagesy($im1));

header('Content-type: image/gif');

Answer Source

imagegif already does that for you if you pass the location of a file to which you want to save to as 2nd parameter to that function.

imagegif($im2);    //output raw image stream directly
imagegif($im2, 'path/to/image_save.gif');    //saves to the file at mentioned path

Although, it must be noted that if path/to/image_save.gif already exists, it will be overwritten.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download