| Current Path : /home/jeromecohp/www/aesecure/premium/third/smartoptimizer/images/ |
| Current File : /home/jeromecohp/www/aesecure/premium/third/smartoptimizer/images/png.php |
<?php
// @file : /premium/third/smartoptimizer/images/png.php
// @version : 2.0.2
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : http://www.aesecure.com/
// @package : 2015-02-14 13:37:46
// @license : This program is a commercial software. You CAN'T redistribute it and/or modify it.
// Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.
?>
<?php
function optimize_png($arr){
$imageFileName=isset($arr['filename'])?$arr['filename']:'';
$newImageFileName=isset($arr['cache'])?$arr['cache']:'';
$maxImgWidth=isset($arr['maxImgWidth'])?$arr['maxImgWidth']:99999;
$decreaseRatio=isset($arr['DecreaseRatio'])?$arr['DecreaseRatio']:1;if((trim($imageFileName)!='')&&(trim($newImageFileName)!='')){
$imgSrc = imagecreatefrompng($imageFileName);
list($width,$height) = getimagesize($imageFileName);if(($width > $maxImgWidth)||($decreaseRatio<1)){
if($decreaseRatio<1){
$newwidth = $width * $decreaseRatio;if(($maxImgWidth>0)&&($newwidth>$maxImgWidth)) $newwidth=$maxImgWidth;} else{
$newwidth = ($width > $maxImgWidth)?$maxImgWidth:$width;}
$newheight = ($height / $width) * $newwidth;
$imgNew = imagecreate($newwidth,$newheight);
imagecopyresampled($imgNew,$imgSrc, 0, 0, 0, 0,$newwidth,$newheight,$width,$height);
imagepng($imgNew,$newImageFileName, 5);
imagedestroy($imgSrc);
imagedestroy($imgNew);
$resizedFlag = true;} else{
copy($imageFileName,$newImageFileName);}} return $newImageFileName;}