Advertisement
Guest User

Thumbnail Generator

a guest
Oct 7th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. $image = $_GET['image'];
  3.  
  4. $regex = '#([a-zA-Z0-9]+)_thumb\.(png|jpe?g|gif)$#';
  5.  
  6. preg_match($regex, $image, $matches);
  7.  
  8. unset($image);
  9. unset($regex);
  10.  
  11. $directory = '/home/user/public_html/images';
  12. $image = sprintf("%s/%s.%s", $directory, $matches[1], $matches[2]);
  13.  
  14. if(file_exists($image)) {
  15.     $thumb = sprintf("%s/%s_thumb.%s", $directory, $matches[1], $matches[2]);
  16.     shell_exec(sprintf("convert -interlace line -quality 80 -size 220x220 %s -resize 220 -profile '*' %s", $image, $thumb));
  17.         echo 'Image Created Successfully!';
  18. } else {
  19.     header("Status: 404 Not Found");
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement