I am currently using imagick
for image processing on my webssite. I have it correctly installed and is working great. Heres my starting code -:
$image = new imagick($filename); $geo=$image->getImageGeometry();
$image->setImageInterlaceScheme(2); $image->setImageCompressionQuality(85);
$image->setImageBackgroundColor('white'); $image = $image->flattenImages();
$image->setImageFormat('jpg'); $image->stripImage();
After this i do the rest of the part. Now suppose it throws an error, how do i code for that. I tried adding if(!$image){ echo 'error' exit(); }
after $image = new imagick($filename)
but in vain.
Please help... Thanks all :)
Imagick is a PHP extension to create and modify images using the ImageMagick library. There is also a version of Imagick available for HHVM. Although the two extensions are mostly compatible in their API, and they both call the ImageMagick library, the two extensions are completely separate code-bases.
Use ImageMagick®to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF.
Imagick is a PHP extension which provides better image quality for media uploads, smarter image resizing (for smaller images) and PDF thumbnail support, when Ghost Script is also available.
If an error occurs, Imagick will throw an ImagickException
which you can catch:
try {
$image = new Imagick($filename);
$geo = $image->getImageGeometry();
$image->setImageInterlaceScheme(2);
$image->setImageCompressionQuality(85);
$image->setImageBackgroundColor('white');
$image = $image->flattenImages();
$image->setImageFormat('jpg');
$image->stripImage();
} catch (ImagickException $e)
{
var_dump($e);
}
for further reference see here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With