go to bug id or search bugs for
Add a Patch
Add a Pull Request
Try calling $im->setFormat("ico"); before readImageBlob(). Does this help?
tried to setImageFormat('ico') before readImageBlob, it
returns an exception saying cannot perform it on an empty
exception happened ImagickException Object (
[message:protected] => Can not process empty Imagick object
[string:private] => [code:protected] => 1 [file:protected]
=> /home/y/share/htdocs/testimagick.php [line:protected] =>
24 [trace:private] => Array (  => Array ( [file] =>
/home/y/share/htdocs/testimagick.php [line] => 24 [function]
=> setimageformat [class] => Imagick [type] => -> [args] =>
Array (  => ico ) ) ) )
setFormat, not setImageFormat.
Thanks a lot for the quick replies and great work on imagick ;-)
I tried setFormat('ico'), now, I don't get "cannot process empty Imagick object" exception anymore. But still I cannot get the ico image output correctly. The output is an ugly looking image (maybe this is because ico has multiple images embedded inside?). Here is the code I tried:
$imageStr = file_get_contents('favicon.ico');
$im = new Imagick();
Previously, when I create an Imagick object from file using constructor and then setImageFormat('png'), it worked fine and I can get a 24x24 image. Here is the code that works for comparison:
$im = new Imagick('favicon.ico');
Sorry, but your problem does not imply a bug in PECL itself. For a
list of more appropriate places to ask for help using PECL, please
visit http://pecl.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PECL.
Imagick passes the image to ImageMagick for processing and usually can not affect the quality of output except by setting some properties. Therefore I am closing this bug.
I am not sure I fully understand what the problem is here.
Thanks for the quick reply.
I guess the problem here is that when you convert ICO image
as a whole to other formats, it does not work and creates
So, you need to get one of the images contained inside the
ICO image and convert the individual image.
But I still don't understand why when you write the ICO
image content to a file then read from the file, the
conversion works fine.
Have you tried flattenImages to merge the layers? Image formats which have multiple images in them are presented in this way because it is the only way to access the individual frames if needs be.
../favicon.ico ICO 32x32 32x32+0+0 DirectClass 8-bit
../favicon.ico ICO 16x16 16x16+0+0 DirectClass 8-bit
../favicon.ico ICO 48x48 48x48+0+0 DirectClass 8-bit
../favicon.ico ICO 24x24 24x24+0+0 DirectClass 8-bit
create imagick obj from image string then do flattenImages,
it returns a normal ICO image, but the result is the size of
the first image inside the ICO, 32x32 in this case
If you open the ICO file in the browser directly, you get a
different size, 16x16
I also tried to read from ICO file directly, it outputs the
last image inside the ICO, 24x24
So, I guess either using flattenImages or traversing through
individual images both will work. But not really sure what
should be the correct size. Maybe it is upto the user