http://www.techrepublic.com/article/10-tips-for-php-scripts-create-and-manipulate-images/5077724
(written by Julie Meloni, dated 2/6/2001)
For example, if you wanted to make a (35x35 thumbnail) from a full sized image, here's a sample code snippet from the main article:
<? /* send a header so that the browser knows the content-type of the file */
header("Content-type: image/png");
/* set up variables to hold the height and width of your new image */
$newWidth = 35;
$newHeight = 35;
/* create a blank, new image of the given new height and width */
$newImg = ImageCreate($newWidth,$newHeight);
/* get the data from the original, large image */
$origImg = ImageCreateFromPNG("test.png");
/* copy the resized image. Use the ImageSX() and ImageSY functions to get the x and y sizes of the orginal image. */
ImageCopyResized($newImg,$origImg,0,0,0,0,$newWidth,$newHeight,ImageSX($origImg),ImageSY($origImg));
/* create final image and free up the memory */
ImagePNG($newImg);
ImageDestroy($newImg);
?>
No comments:
Post a Comment