SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with Thumbnail Script

    Hi all -

    Trying to work out some problems with my thumbnail script.

    here is my script:



    PHP Code:
    //thumbnail width and height
    $t_width 250;
    $t_height 200;

    //get file information            
    list($width$height$type) = getimagesize("$dir/$fname/$file");
                
        
    $ratio_orig $width/$height;

            if (
    $t_width/$t_height $ratio_orig) {
                
    $t_width $t_height $ratio_orig;
                    } else {
                        
    $t_height $t_width/$ratio_orig;
                        }
                
        
    //Resize
        
    $thumb imagecreatetruecolor($t_width$t_height);
        
    $src imagecreatefromjpeg("$dir/$fname/$file");
                
        
    imagecopyresampled($thumb$src0000$t_width$t_height$width$height);
                
        
    imagejpeg($thumb"{$dir}/{$fname}/thumbs/{$file}"100); 

    I'm getting a number of errors that are giving me a headache, let me start with two:

    1) $thumb = imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions
    I'm getting great thumbanails for both portrait and landscape - any idea as to why this warning is occuring?

    2) imagejpeg() expects parameter 1 to be resource, boolean given.
    I suspect this has to do with my first warning but not sure how to move forward.

    Thanks in advance - I'm new to this area of php and any help would be appreciated.

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,438
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    I would echo the values of $t_width and $t_height before this line //Resize to see what they contain.


Bookmarks

Posting Permissions

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