first sorry for my bad english!! But i´m working to make it better
Since 1 week i try to make a small thumbnail with rounded corner.
This was no problem with imagick!
Great Tool, but the size of the PNG-File i get is always arround 93kB!!! The size is only 195x130px :s
Is there a way to copress this PNG?? I Tried the following things:
Code: Select all
$newimage->setCompression(Imagick::COMPRESSION_ZIP);
$newimage->setCompressionQuality(30);
$newimage->setImageCompression(Imagick::COMPRESSION_ZIP);
$newimage->setImageCompressionQuality(30);
$newimage->setImageInterlaceScheme(Imagick::INTERLACE_PNG);
$newimage->setImageDepth(8);
Code: Select all
$newWidth = 195;
$newHeight = 130;
$newimage = new Imagick();
$newimage->newImage( $newWidth, $newHeight + 20, new ImagickPixel( "#DBDBDB" ) );
$image = new Imagick($tempFile);
$image->stripImage();
$imageWidth = $image->getImageWidth();
$imageHeight = $image->getImageHeight();
$ratioWidth = $newWidth/$imageWidth;
$ratioHeight = $newHeight/$imageHeight;
if ($ratioWidth < $ratioHeight){
$ratio = $ratioHeight;
$newCutWidth = $newWidth;
$newCutHeight = $newHeight;
$newHeight = intval($ratio * $imageHeight);
$newWidth = intval($ratio * $imageWidth);
}
else {
$newCutWidth = $newWidth;
$newCutHeight = $newHeight;
$ratio = $ratioWidth;
$newHeight = intval($ratio * $imageHeight);
$newWidth = intval($ratio * $imageWidth);
}
$image->resizeImage($newWidth, $newHeight,0,1);
$image->cropImage($newCutWidth,$newCutHeight, 0,0);
$newimage->compositeImage( $image, Imagick::COMPOSITE_OVER, 0, 0 );
$image->destroy();
$newimage->setImageFormat("png");
$newimage->roundCorners(2,2);
$newimage->cropImage($newCutWidth,$newCutHeight,0,0);
$newimage->setCompression(Imagick::COMPRESSION_ZIP);
$newimage->setCompressionQuality(30);
$newimage->setImageCompression(Imagick::COMPRESSION_ZIP);
$newimage->setImageCompressionQuality(30);
$newimage->setImageInterlaceScheme(Imagick::INTERLACE_PNG);
$newimage->setImageDepth(8);
$sql = "INSERT into images (thumb, ID) VALUES ('" . $db->escape($newimage->getImageBlob()) . "', '" . $imageID . "')";
$db->execute($sql);
$fh = fopen("gallery/thumbs/" . $imageID . ".png","w+");
fwrite($fh,$newimage);
fclose($fh);
$newimage->destroy();
Or somebody who can tell me, what i´m doing wrong?
Thanks in advance!!!
Basti