Home >Backend Development >PHP Tutorial >关于php图片等比例缩放函数的.谁能帮我看看我这个函数怎么用啊?

关于php图片等比例缩放函数的.谁能帮我看看我这个函数怎么用啊?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:18:311355browse

<code>function resize($srcImage,$toFile,$maxWidth = 100,$maxHeight = 100,$imgQuality=100) 
{ 
   
    list($width, $height, $type, $attr) = getimagesize($srcImage); 
    if($width </code>

回复内容:

<code>function resize($srcImage,$toFile,$maxWidth = 100,$maxHeight = 100,$imgQuality=100) 
{ 
   
    list($width, $height, $type, $attr) = getimagesize($srcImage); 
    if($width </code>

因为tofile($srcImage,$toFile)第二个参数$toFile自己指定的话存在格式问题,比如srcImage是jpg,但是如果你填写的toFile是png,那格式就对不上了,因此如果你制定了toFile的文件后缀,那就直接干掉,然后在直接将原图片的格式追加在你指定的toFile后面。

--

简单来说:
tofile('a.jpg','b.png');
最终生成的是b.jpg而不是b.png

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn