大佬教程收集整理的这篇文章主要介绍了基于PHP实现等比压缩图片大小,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
废话不多说了,直接给大家贴PHP等比压缩图片大小的相关代码了,具体代码如下所示:
php;"> $maxwidth) && ($maxheight && $pic_height > $maxheight)) { if($maxwidth && $pic_width>$maxwidth) { $widthratio = $maxwidth/$pic_width; $resizewidth_tag = true; } if($maxheight && $pic_height>$maxheight) { $heightratio = $maxheight/$pic_height; $resizeheight_tag = true; } if($resizewidth_tag && $resizeheight_tag) { if($widthratio<$heightratio) $ratio="$widthratio;" else="" $ratio="$heightratio;" }="" if($resizewidth_tag="" &&="" !$resizeheight_tag)="" $ratio="$widthratio;" if($resizeheight_tag="" &&="" !$resizewidth_tag)="" $ratio="$heightratio;" $newwidth="$pic_width" *="" $ratio;="" $newheight="$pic_height" *="" $ratio;="" if(function_exists("imagecopyresampled"))="" {="" $newim="imagecreatetruecolor($newwidth,$newheight);" imagecopyresampled($newim,$im,$newwidth,$newheight,$pic_width,$pic_height);="" }="" else="" {="" $newim="imagecreate($newwidth,$newheight);" imagecopyresized($newim,$pic_height);="" }="" $name="$name.$filetype;" imagejpeg($newim,$name);="" imagedestroy($newim);="" }="" else="" {="" $name="$name.$filetype;" imagejpeg($im,$name);="" }="" }="">$heightratio)>
以上是大佬教程为你收集整理的基于PHP实现等比压缩图片大小全部内容,希望文章能够帮你解决基于PHP实现等比压缩图片大小所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。