Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. $src_img=imagecreatefrompng($name); //Loads the source image's name and location, either from a variable or (preferably) an array
  2. $old_x=imageSX($src_img); //Get's the source image's with
  3. $old_y=imageSY($src_img); //Get's the source image's height
  4. $dst_img=ImageCreateTrueColor(170,40); //Creates a canvas for the thumbnail, 170x40.
  5. 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
  6. imagepng($dst_img,$thumbsfolder."/".$filename); //Saves the new thumbnail to whatever folder/filename you want.
  7. imagedestroy($dst_img); //Deletes the thumbnail image from ram, as it's no longer needed.
  8. 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