/ Published in: PHP

Only JPG
Expand |
Embed | Plain Text
<?php /* File: thumbs.php Example: <img src="thumbs.php?filename=photo.jpg&width=100&height=100"> */ $filename= $_GET['filename']; $width = $_GET['width']; $height = $_GET['height']; $path="http://localhost/images/"; //finish in "/" // Content type // Get new dimensions if ($width && ($width_orig < $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($path.$filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100); // Imagedestroy imagedestroy ($image_p); ?>
Comments

You need to login to post a comment.
looks nice, but not very useful without caching.. Error handling is missing too and it won't hurt to support PNG and GIF too...
ImageMagick version should be nicer, i suppose. And this can be "reduced" version, if IM or MagicWand is not installed.
you could also use http://freelogic.pl/thumbnailer/
Shocker: right :) ... not really useful without caching / error handling
A nice OOP-PHP5-Class for crating Thumbnails: https://github.com/SteffenHagdorn/Pixlie