Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    GD imagecopyresampled(): not a valid image resource

    Hi, I'm using a script to create thumnails. I'm getting the following error when trying to use a PNG image as the basic image:

    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/.peasy/metroid48/thefreewarecentral.com/pass/add_ss.php on line 87'

    Here's the script it's using:

    PHP Code:
    function Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path) {
        
    $s_path trim($s_path);
        
    $o_path trim($o_path);
        
    $save $s_path $save;
        
    $file $o_path $file;
        
    $ext substr(($save), 1);
    //    $ext = strtolower(end(explode('.',$save)));
        
    list($width$height) = getimagesize($file) ;
        if((
    $width>$t_w) OR ($height>$t_h)) {
            
    $r1 $t_w/$width;
            
    $r2 $t_h/$height;
            if(
    $r1<$r2) {
              
    $size $t_w/$width;
            }else{
              
    $size $t_h/$height;
            }
        }else{
            
    $size=1;
        }
        
    $modwidth $width $size;
        
    $modheight $height $size;
        
    $tn imagecreatetruecolor($modwidth$modheight) ;
        switch (
    $ext) {
            case 
    'jpg':
            case 
    'jpeg':
                        
    $image imagecreatefromjpeg($file) ;
            break;
            case 
    'gif':
                        
    $image imagecreatefromgif($file) ;
            break;
            case 
    'png':
                        
    $image imagecreatefrompng($file) ;
            break;
        }
        
    imagecopyresampled($tn$image0000$modwidth$modheight$width$height) ;
        
    imagejpeg($tn$save100) ;
        return;

    Any ideas? This only happens on PNGs, not jpgs or gifs.

    Thanks,
    -Metroid48

  • #2
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe your gd library does not have support yet for png images..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •