PHP supports jpg, png, and gif formats to scale up or down the image class according to the maximum width and height.
Orpic = $ file; $ infos = getimagesize ($ file); $ this-> width = $ infos [0]; $ this-> height = $ infos [1]; $ this-> type = $ infos [2];} // calculate the thumbnail size based on the maximum width and height specified by the user. function cal_size ($ maxwidth, $ maxheight) {// ratio of the maximum width and height of a thumbnail $ thcrown = $ maxwidth/$ maxheight; // ratio of the original image width to height $ crown = $ this-> width/$ this-> height; if ($ crown/$ thcrown> = 1) {$ this-> thwidth = $ maxwidth; $ this-> thheight = $ maxwidth/$ crown ;} else {$ this-> thheight = $ Maxheight; $ this-> thwidth = $ maxheight * $ crown;} function init () {switch ($ this-> type) {case 1: // GIF $ this-> tempic = imagecreatefromgif ($ this-> orpic); break; case 2: // JPG $ this-> tempic = imagecreatefromjpeg ($ this-> orpic); break; case 3: // PNG $ this-> tempic = imagecreatefrompng ($ this-> orpic); break; default: echo 'This image format is not supported temporarily ';} function resize ($ maxwidth, $ maxheight) {// initialize the image $ this-> init (); // Calculate the thumbnail size $ this-> cal_size ($ maxwidth, $ maxheight); $ this-> thpic = imagecreatetruecolor ($ this-> thwidth, $ this-> thheight ); imagecopyresampled ($ this-> thpic, $ this-> tempic, 0, 0, 0, 0, $ this-> thwidth, $ this-> thheight, $ this-> width, $ this-> height);} function save ($ filename, $ type) {switch ($ type) {case 'jpg ': case 'jpeg ': imagejpeg ($ this-> thpic, $ filename); break; case 'PNG ': imagepng ($ this-> thpic, $ file Name); break; case 'GIF': imagegif ($ this-> thpic, $ filename); break; default: echo 'The format you selected is not supported temporarily '; }}}?>