Code:
$filename = "des_big.jpg"; list ($src _w, $src _h, $imagetype) =getimagesize ($filename); $mime =image_type_to_mime_type ($ imagetype);//echo $mime;//output is Imae/jpeg$createfun=str_replace ("/", "CreateFrom", $mime);//imagejpeg () $outFun =str_ Replace ("/", NULL, $mime), $src _image= $createFun ($filename); $dst _50_image=imagecreatetruecolor (50,50); $DST _220_ Image=imagecreatetruecolor (220,220); $dst _350_image=imagecreatetruecolor (350,350); $DST _800_image= Imagecreatetruecolor (800,800) imagecopyresampled ($dst _50_image, $src _image,0,0,0,0,50,50, $src _w, $src _h); Imagecopyresampled ($dst _220_image, $src _image,0,0,0,0,220,220, $src _w, $src _h); imagecopyresampled ($dst _350_image, $src _image,0,0,0,0,350,350, $src _w, $src _h) imagecopyresampled ($dst _800_image, $src _image,0,0,0,0,800,800, $src _w, $src _h); $outFun ($dst _50_image, "uploads/image_50/". $filename); $outFun ($dst _220_image, "uploads/image_220/". $ filename); $outFun ($dst _350_image, "uploads/image_350/". $filename); $outFun ($dst _800_image, "Uploads/image_800/". $ filename); Imagedestroy ($src _image); IMAgedestroy ($dst _50_image); Imagedestroy ($dst _220_image); Imagedestroy ($dst _350_image); Imagedestroy ($dst _800_ image);
Finally, a picture of 50*50,220*220,350*350,800*800 is generated and there are uploads/image_50, uploads/image_220, uploads/image_350, Uploads/image, respectively. _800 in the folder.
The function description in the code:
Image_type_to_mime_type-gets the MIME type of the image type returned by Getimagesize,exif_read_data,exif_thumbnail,exif_imagetype
Create multiple thumbnails of a single picture and save