note 59426 deleted from function.imagecopyresampled by cmb
| From: | cmb@php.net | Date: | Wed, 12 Oct 2016 15:43:29 +0000 |
| Subject: | note 59426 deleted from function.imagecopyresampled by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206858@lists.php.net to get a copy of this message | ||
Note Submitter: smrtak at 4um dot cz
----
class cobrazek
{
function resizeMaxJpeg($file,$mx,$my,$q=85)
{
$dst = cobrazek::resizeMax(imagecreatefromjpeg($file),$mx,$my);
if(!$dst)
return false;
if(!imagejpeg($dst,$file,$q))
return false;
return true;
}
function resizeMax($src,$mx,$my)
{
//zjisti velikost
$sx = imagesx($src);
$sy = imagesy($src);
//spocitej cilovou velikost
$v = min(min($mx,$sx)/$sx,min($my,$sy)/$sy);
$dx = $v*$sx;
$dy = $v*$sy;
$dst = imagecreatetruecolor($dx,$dy);
//resample
imagecopyresampled ($dst,$src,0,0,0,0,$dx,$dy,$sx,$sy);
//vystup
return $dst;
}
}