Published in: PHP
Only JPG
<?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
Subscribe to 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...