I am trying to create a piece of code that will create and display
thumbnail image. When trying to send the image to a browser, I see
binary data rather then an image. You can see the problem at

The troubled cose for this page follows:


//a master image may be any image of any size

//If the master image exists, the thumb will be created and output to
the browser

//requires path from the file system home directory as

//requires the name of the master image as $master image        

//test variables -- will eventually be defined by the calling module
$master_image_path = "/home/html/74ranch/uploads/";
$master_image = "chex34.jpg";

        $thumb_width = 80;
}//end if

//make sure that the master file exists
$master_image_all = "$master_image_path";
$master_image_all .= "$master_image";

//remove this section after coding is complete
        $master_image_all_link = "/74ranch/uploads/";
        $master_image_all_link .= "$master_image";
        print("<img src = $master_image_all_link>");

        $size = getimagesize("$master_image_all");
        $width = $size[0];
        $height = $size[1];

                //calculate thumb height
                $factor = $width / $thumb_width;
                $thumb_height = $height * $factor;
                $thumb_height = $thumb_height * .1;
                $thumb_height = round($thumb_height);
                print("<P> Origional: height: $height width:            
height:$thumb_height width:             $thumb_width<P>");
                //build the thumbnail 
                $src_img = imagecreatefromjpeg("$master_image_all");
                $dst_img = imagecreate($thumb_width,$thumb_height);
                //$dst_img =
 gd 2.0
or higher
                print("<P>Variables that will be inserted into the              
                print("<BR>width: $width");
                print("<br>height $height");
                print("<br>thumb_width $thumb_width");
                print("<br>thumb_height $thumb_height");
                print("<P>Display the new thumb image<P>");
                imagecopyresized($dst_img, $src_img, 0, 0, 0, 0,                
$thumb_height, $width, $height);
                //imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,            
$thumb_height, $width, $height);//requires gd           2.0 or higher
                //imagejpeg($dst_img, "path and file name", 75);//saves                
 the image to
a file
                imagejpeg($dst_img, '', 50);//sends the image to the            browser


}//end if

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to