php gd2 thumbnail creator script problem

371 views Asked by At

I have this script:

 function createThumb($source, $thumb_width=100)
        {
     $fl = dirname($source).'<br>';
     $new_name = 'thumb_'.basename($source);
     $img = imagecreatefromjpeg($source);
     $width = imagesx($img);
     $height = imagesy($img);
     $new_width = $thumb_width;
     $new_heght = floor($height * ($thumb_width / $width));
     $tmp_name = imagecreatetruecolor( $new_width, $new_heght );
     imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_heght, $width, $height);
      imagejpeg($tmp_img, $fl.DIRECTORY_SEPARATOR.$new_name);
        }

All data works fine. I echo every step to imagecopyresized where I get this warning.

Warning: imagecopyresized(): supplied argument is not a valid Image resource in /www/mdkbg.com/keasport/root/admin/parsing_vars.php5 on line 41

what could be the problem? I've changed the folder permission to 755 and I use php5 file tipes.

1

There are 1 answers

2
qbert220 On BEST ANSWER
$tmp_name = imagecreatetruecolor( $new_width, $new_heght );

should read:

$tmp_img = imagecreatetruecolor( $new_width, $new_heght );