Results 1 to 4 of 4

Thread: PHP Image Thumbnail Script Not Working

  1. #1
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default PHP Image Thumbnail Script Not Working

    http://www.partdigital.com/tutorials/gd-thumbnail/

    I cant get this script to work on my server I have GD installed. I think I am doing something wrong. Can some one put the whole scrip together for me...

  2. #2
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Quote Originally Posted by benslayton View Post
    http://www.partdigital.com/tutorials/gd-thumbnail/

    I cant get this script to work on my server I have GD installed. I think I am doing something wrong. Can some one put the whole scrip together for me...
    Hi!

    Heres the script!

    PHP Code:
    <?php

    //Your Image 
    $imgSrc "image.jpg";  

    //getting the image dimensions 
    list($width$height) = getimagesize($imgSrc);  

    //saving the image into memory (for manipulation with GD Library) 
    $myImage imagecreatefromjpeg($imgSrc);

    ///-------------------------------------------------------- 
    //setting the crop size 
    //-------------------------------------------------------- 
    if($width $height$biggestSide $width;  
    else 
    $biggestSide $height;  

    //The crop size will be half that of the largest side  
    $cropPercent .5;  
    $cropWidth   $biggestSide*$cropPercent;  
    $cropHeight  $biggestSide*$cropPercent;  


    //getting the top left coordinate 
    $c1 = array("x"=>($width-$cropWidth)/2"y"=>($height-$cropHeight)/2);

    //-------------------------------------------------------- 
    // Creating the thumbnail 
    //-------------------------------------------------------- 
    $thumbSize 60;  
    $thumb imagecreatetruecolor($thumbSize$thumbSize);  
    imagecopyresampled($thumb$myImage00$c1['x'], $c1['y'], $thumbSize$thumbSize$cropWidth$cropHeight);

    //-------------------------------------------------------- 
    // Creating the lines 
    //-------------------------------------------------------- 
    $lineWidth 1
    $margin    0;   
    $green    imagecolorallocate($thumb193252182); 

    for(
    $i=0$i<2$i++){ 
        
    //left line 
        
    imagefilledrectangle($thumb$margin$margin$margin+$lineWidth$thumbSize-$margin$green);  
        
    //right line 
        
    imagefilledrectangle($thumb$thumbSize-$margin-$lineWidth$margin$thumbSize-$margin$thumbSize-$margin$green); 
        
    //topLine 
        
    imagefilledrectangle($thumb$margin$margin$thumbSize-$margin-$lineWidth$margin+$lineWidth$green);  
        
    //bottom line  
        
    imagefilledrectangle($thumb$margin$thumbSize-$margin-$lineWidth$thumbSize-$margin-$lineWidth$thumbSize-$margin,$green); 
        
    $margin+=4;  
    }

       
    //final output   
        
    header('Content-type: image/jpeg'); 
        
    imagejpeg($thumb); 
        
    imagedestroy($thumb);   

    ?>
    Best regards,
    mbrodin

  3. #3
    Join Date
    May 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by benslayton View Post
    http://www.partdigital.com/tutorials/gd-thumbnail/

    I cant get this script to work on my server I have GD installed. I think I am doing something wrong. Can some one put the whole scrip together for me...
    What is exactly breaking? Do you have any error messages, etc? Are you using jpg and gifs?

    Thanks!
    hanji

  4. #4
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    No i figured out that in every box that he had with code there were some "<?Php" starting tags and no ending tags. I just had to take out all the tags and have one at the top of the document and one at the bottom of the document.

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
  •