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.
<?php
$time=time();
$neww = 65;
$newh = 87;
$file=htmlspecialchars($_GET['file']);
list(, , $type,)=getimagesize($file);
if($type==1) {
$funci='imagecreatefromgif';
} //$funco='imagegif';}
if($type==2) {
$funci='imagecreatefromjpeg';
} //$funco='imagejpeg';}
if($type==3) {
$funci='imagecreatefrompng';
} //$funco='imagepng';}
if($type) {
$im1 = $funci($file);
$im2=imagecreatetruecolor($neww,$newh);
imagecopyresized($im2, $im1, 0,0,0,0,$neww,$newh, imagesx($im1), imagesy($im1));
header('Content-type: image/gif');
imagegif($im2);
}
?>
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.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments