Hi there,
I am uploading jpegs in my app. How can I control the compression setting
before saving?
Currently my code looks like:
########################################################################
$inputImg = ImageCreateFromJPEG($image);
# old size
$srcX = imagesx($inputImg);
$srcY = imagesy($inputImg);
if ($same == true){ // Image must have the given size. Empty parts are
filled black.
# new size
$ratio = ($srcY / $dstY);
$dstX = ($srcX / $ratio);
$outputImg = ImageCreateTrueColor($maxX, $dstY);
imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 0, 0,0));
imagecopyresampled($outputImg, $inputImg, (($maxX - $dstX) / 2),0,0,0,
$dstX, $dstY, $srcX, $srcY);
}
else{ // Image has a y ratio size. Results in not all images same y size.
# new size
$ratio = ($srcX / $maxX);
$dstY = ($srcY / $ratio);
$outputImg = ImageCreateTrueColor($maxX, $dstY);
imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 0, 0,0));
imagecopyresampled($outputImg, $inputImg, 0,0,0,0, $maxX, $dstY, $srcX,
$srcY);
}
# save file
imagejpeg($outputImg, $path.$name.".jpg");
########################################################################
Thanx for any help.
Cheers Andy
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]