/**
按照比例改变图片大小(非生成缩略图)
@param string $img 图片路径
@param int $max_w 最大缩放宽
@param int $max_h 最大缩放高
*/
function chImageSize ($img,$max_w,$max_h)
{
$size = @getimagesize($img);
$w = $size[0];
$h = $size[1];
//计算缩放比例
@$w_ratio = $max_w / $w;
@$h_ratio = $max_h / $h;
//决定处理后的图片宽和高
if( ($w
{
$tn['w'] = $w;
$tn['h'] = $h;
}
else if(($w_ratio * $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 ;
}
?>
函数描述及例子
按照比例改变图片大小(非生成缩略图)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
