The function prototype is as follows: parameter description: $ oldwidth: Original image width $ oldheight: Original Image Height $ imgwidth: reduced or enlarged image width $ imgheight: reduced or enlarged image height returned: array: arraysize, where the index is: width and height, that is, arraysize [width], arraysize [height] functi
The function prototype is as follows:
Parameter description:
$ Oldwidth: Original image width
$ Oldheight: Original image height
$ Imgwidth: the image width that is reduced or enlarged.
$ Imgheight: The Image height that is reduced or enlarged.
Return value:
Array: arraysize, where the index is: width and height, I .e.: arraysize ['width'], arraysize ['height']
Function getimgsize ($ oldwidth, $ oldheight, $ imgwidth, $ imgheight)
{
// $ Width set by oldwidth, $ height set by oldheight, $ width of the imgwidth image, and $ height of the imgheight image;
// If a cell can be loaded into an image, it is displayed according to the actual size of the image;
If ($ imgwidth <= $ oldwidth & $ imgheight <= $ oldheight)
{
$ Arraysize = array ('width' => $ imgwidth, 'height' => $ imgheight );
Return $ arraysize;
}
Else
{
$ Suoxiaowidth = $ imgwidth-$ oldwidth;
$ Suoxiaoheight = $ imgheight-$ oldheight;
$ Suoxiaoheightper = $ suoxiaoheight/$ imgheight;
$ Suoxiaowidthper = $ suoxiaowidth/$ imgwidth;
If ($ suoxiaoheightper >=$ suoxiaowidthper)
{
// The cell height shall prevail;
$ Aftersuoxiaowidth = $ imgwidth * (1-$ suoxiaoheightper );
$ Arraysize = array ('width' => $ aftersuoxiaowidth, 'height' => $ oldheight );
Return $ arraysize;
}
Else
{
// The cell width prevails;
$ Aftersuoxiaoheight = $ imgheight * (1-$ suoxiaowidthper );
$ Arraysize = array ('width' => $ oldwidth, 'height' => $ aftersuoxiaoheight );
Return $ arraysize;
}
}
}