Copy CodeThe code is as follows:
/**********************
* @filename-path to the image
* @tmpname-temporary path to thumbnail
* @xmax-max width
* @ymax-max Height
*/
function Resize_image ($filename, $tmpname, $xmax, $ymax)
{
$ext = Explode (".", $filename);
$ext = $ext [Count ($ext)-1];
if ($ext = = "JPG" | | $ext = = "JPEG")
$im = Imagecreatefromjpeg ($tmpname);
ElseIf ($ext = = "png")
$im = Imagecreatefrompng ($tmpname);
ElseIf ($ext = = "gif")
$im = Imagecreatefromgif ($tmpname);
$x = Imagesx ($im);
$y = Imagesy ($im);
if ($x <= $xmax && $y <= $ymax)
return $im;
if ($x >= $y) {
$newx = $xmax;
$newy = $newx * $y/$x;
}
else {
$newy = $ymax;
$NEWX = $x/$y * $NEWY;
}
$im 2 = Imagecreatetruecolor ($newx, $newy);
Imagecopyresized ($im 2, $im, 0, 0, 0, 0, Floor ($newx), Floor ($newy), $x, $y);
return $im 2;
}
Here is an excerpt from the article published before this site. More tips can be used for reference.
21 useful and convenient PHP function codes collected
The above describes the iphone wallpaper size PHP image sizing code, including the size of the iphone wallpaper, I hope to be interested in PHP tutorial friends helpful.