Php uses the GD library to Create Image thumbnails,
This example describes how to use the GD library to Create Image thumbnails in php. Share it with you for your reference. The specific analysis is as follows:
Upload the static html code of the page:
<Html>
The corresponding Upload. php file code:
<? Php $ uploadfile = "upfiles /". $ _ FILES ['upfile'] ['name']; // name and path of the uploaded file $ smallfile = "upfiles/small _". $ _ FILES ['upfile'] ['name']; // name and path of the uploaded thumbnail file if ($ _ FILES ['upfile'] ['type']! = "Image/pjpeg") {echo "file type error "; // output error message} else {move_uploaded_file ($ _ FILES ['upfile'] ['tmp _ name'], $ uploadfile); // uploads a file $ dstW = 200; // set the width of the thumbnail. $ dsomething = 200; // set the height of the thumbnail. $ src_image = ImageCreateFromJPEG ($ uploadfile ); // read the JPEG file and create an image object $ srcW = ImageSX ($ src_image); // obtain the image width $ srcH = ImageSY ($ src_image ); // obtain the Image Height $ dst_image = ImageCreateTrueColor ($ dstW, $ dsomething); // create a new image object ImageCopyResized ($ dst_image, $ s Rc_image, 0, 0, 0, $ dstW, $ dsomething, $ srcW, $ srcH); // redefines the image size and writes it to the new image object ImageJpeg ($ dst_image, $ smallfile); // create the thumbnail file echo "File Uploaded <BR> "; // output the uploaded information echo " </img>"; // display the thumbnail on the page}?>
I hope this article will help you with php programming.