简体   繁体   中英

php gd2 thumbnail creator script problem

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.

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

应该读:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM