Jump to content

[SOLVED] Problem with image thumbnail function


evanct

Recommended Posts

I posted this the other day but the issue resolved itself somehow. Now it's back again - even though I didn't even change the script! It's confusing. The problem is the image that's created is completely black. It's the correct dimensions and it's placed in the correct directory, but it's just a black square. Here's the troublemaker:

 

function createThumbnail($path,$tn_src,$thumb_size) {
require('config.php');

    $size = getimagesize($path);
    $width = $size[0];
    $height = $size[1];

    if($width> $height) {
        $x = ceil(($width - $height) / 2 );
        $width = $height;
    } elseif($height> $width) {
        $y = ceil(($height - $width) / 2);
        $height = $width;
    }

    $new_im = ImageCreatetruecolor($thumb_size,$thumb_size);
    $im = imagecreatefromjpeg($path);
    imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
    imagejpeg($new_im,$tn_src,100);
}

 

If there's something wrong I don't see it. do you?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.