Change picture size by scale _php Tutorial

Source: Internet
Author: User
/**
Change the size of the picture proportionally (not generate thumbnails)
@param string $img picture path
@param int $max _w Maximum zoom relaxation
@param int $max _h Max zoom height
*/
function Chimagesize ($img, $max _w, $max _h)
{
$size = @getimagesize ($img);
$w = $size [0];
$h = $size [1];
Calculating the zoom ratio
@ $w _ratio = $max _w/$w;
@ $h _ratio = $max _h/$h;
Determine the image width and height after processing
if (($w <= $max _w) && ($h <= $max _h))
{
$tn [' w '] = $w;
$tn [' h '] = $h;
}
else if (($w _ratio * $h) < $max _h)
{
$tn [' h '] = ceil ($w _ratio * $h);
$tn [' w '] = $max _w;
}
Else
{
$tn [' w '] = ceil ($h _ratio * $w);
$tn [' h '] = $max _h;
}
$tn [' rc_w '] = $w;
$tn [' rc_h '] = $h;
return $tn;
}
?>


function description and examples

Change the size of the picture proportionally (not generate thumbnails)

http://www.bkjia.com/PHPjc/735073.html www.bkjia.com true http://www.bkjia.com/PHPjc/735073.html techarticle ?/** changes the picture size (not generated thumbnail) @param string $img picture path @param int $max _w maximum zoom @param int $max _h Max scale High */function Chimagesi Ze ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.