Get remote Image, resize and save it


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.