Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $src_img=imagecreatefrompng($name); //Loads the source image's name and location, either from a variable or (preferably) an array
- $old_x=imageSX($src_img); //Get's the source image's with
- $old_y=imageSY($src_img); //Get's the source image's height
- $dst_img=ImageCreateTrueColor(170,40); //Creates a canvas for the thumbnail, 170x40.
- imagecopyresampled($dst_img,$src_img,0,0,0,0,170,40,$old_x,$old_y); //Resizes the source image to 170x40 and then copies it to the blank thumbnail canvas
- imagepng($dst_img,$thumbsfolder."/".$filename); //Saves the new thumbnail to whatever folder/filename you want.
- imagedestroy($dst_img); //Deletes the thumbnail image from ram, as it's no longer needed.
- imagedestroy($src_img); //Deletes the source image from ram, as it's no longer needed.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement