Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // takes an input URL of an image, and resize + save into a thumbnail
- // can take a few seconds if large input image
- $re = "/(https?:\\/\\/.*\\.(?:png|jpg|gif))/";
- preg_match($re, $article, $matches);
- $filename = $matches[0];
- list($width, $height) = getimagesize($filename);
- $thumb = imagecreatetruecolor($size, $size);
- $source = imagecreatefromjpeg($filename); break;
- imagecopyresampled($thumb, $source, 0, 0, $width/2 - $height/2, 0, 70, 70, $height, $height);
- imagejpeg($thumb, "./thumbnails/$last_id.jpg");
- imagedestroy($thumb);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement