I’m trying to create some thumbnails of images for a classifieds type page.
My host server is running:
PHP 4.3.2
GD support is:
GD support- enabled
GD version – bundled (2.0.12 compatible)
JPG support – enabled
My code seems to pretty much be working except it’s cropping the image to the thumbnail size rather than shrinking the image. I’m learning this function on the fly and I haven’t been able to track down a reason for this.
I’m hoping someone can spot why and help me out. 😮
If you need more info let me know
Here’s my call code:
[CODE]createThumbnail(“uploaded_files”, “$file”, “uploaded_files/thumbs”, 150);
Here’s the function:
[code]
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth)
{
$srcImg = imagecreatefromjpeg(“$imageDirectory/$imageName”);
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);
echo imagesx($srcImg);
$ratio = $thumbWidth / $origWidth;
$thumbHeight = $origHeight * $ratio;
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, imagesx($thumbImg), imagesy($thumbImg));
Thanks in advance!