Imgtools (Create Thumbnails, Get Img Size)
imgtools.php used in my image gallery. includes function for thumnail creation and for getting width and height of image.
<?php function createThumb($realfile) { $filename = "images/" . $realfile; // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = 160; $newheight = 160; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb, "images/thumb_" . $realfile, 75); } function getWidth($filename) { list($width, $height) = getimagesize($filename); return $width; } function getHeight($filename) { list($width, $height) = getimagesize($filename); return $height; } ?>

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Download this code in plain text format here
Comments: