Posted By

rave on 09/30/10


Tagged

resize image jpg remote download save jpeg


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


Get remote Image, resize and save it


 / Published in: PHP
 

  1. function saveAndResize($filename, $name, $new_width, $new_height, $pathAndFilename){
  2. list($width, $height) = getimagesize($filename);
  3.  
  4. $image_p = imagecreatetruecolor($new_width, $new_height);
  5. $image = imagecreatefromjpeg($filename);
  6. imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  7.  
  8. imagejpeg($image_p, $pathAndFilename);
  9. imagedestroy($image_p);
  10. }

Report this snippet  

You need to login to post a comment.