This article explains how PHP modifies the size of the uploaded image. Share to everyone for your reference. The implementation method is as follows:
<?php//the temporary file created by Php$uploadedfile = $_files[' UploadFile ' [' Tmp_name '];//Create an Image f Rom it so we can do the RESIZE$SRC = Imagecreatefromjpeg ($uploadedfile);//Capture The original size of the uploaded image List ($width, $height) =getimagesize ($uploadedfile),//For our purposes, I has resized the image to be//pixels wide, an D maintain the original aspect//ratio. This prevents the image from being "stretched"//or "squashed". If you prefer some max width other than//, simply change the $newwidth variable$newwidth=600; $newheight = ($height/$widt h) *600; $tmp =imagecreatetruecolor ($newwidth, $newheight);//This line actually does the image resizing, copying from the OR iginal//image into the $tmp imageimagecopyresampled ($tmp, $SRC, 0,0,0,0, $newwidth, $newheight, $width, $height);//Now Write the resized image to disk. I have assumed this want the//resized, uploaded image file to reside in the./images subdirectory. $filename = "Images /". $_files[' UploAdfile ' [' Name '];imagejpeg ($tmp, $filename, +), Imagedestroy ($SRC); Imagedestroy ($tmp);//note:php'll clean up the Temp file It created when the request//have completed.? >
I hope this article is helpful to everyone's PHP programming.