Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. // takes an input URL of an image, and resize + save  into a thumbnail
  2. // can take a few seconds if large input image
  3.  
  4. $re = "/(https?:\\/\\/.*\\.(?:png|jpg|gif))/";
  5. preg_match($re, $article, $matches);
  6. $filename = $matches[0];  
  7.  
  8. list($width, $height) = getimagesize($filename);
  9. $thumb = imagecreatetruecolor($size, $size);
  10. $source = imagecreatefromjpeg($filename); break;
  11.  
  12. imagecopyresampled($thumb, $source, 0, 0, $width/2 - $height/2, 0, 70, 70, $height, $height);
  13. imagejpeg($thumb, "./thumbnails/$last_id.jpg");
  14. imagedestroy($thumb);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement