note 106770 added to function.imagick-flattenimages
| From: | (hi@samuelfine.com) | Date: | Mon, 05 Dec 2011 17:32:57 +0000 |
| Subject: | note 106770 added to function.imagick-flattenimages | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184906@lists.php.net to get a copy of this message | ||
This is also useful for accurately converting .ico files to .png. (Other types as well, in theory,
but I've only tested ico->png.) Simply using setFormat will create a valid .png file, but
will result in image artifacts if the original .ico had any transparency. The following code will
create an accurate copy:
<?php
$im = new Imagick();
// When dealing with .ico files, make sure to setFormat before loading the image or you'll get
a nasty exception. See https://bugs.php.net/bug.php?id=58515 for more
details.
$im->setFormat("ico");
$im->readImage("favicon.ico");
$im = $im->flattenImages(); // Thanks for the tip, Jairu5!
$im->setFormat("png");
$new = fopen("favicon.png", "w");
$im->writeImageFile($new);
$im->clear();
$im->destroy();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 98.229.223.206
----
Manual Page -- http://www.php.net/manual/en/function.imagick-flattenimages.php
Edit -- https://master.php.net/note/edit/106770
Del: integrated -- https://master.php.net/note/delete/106770/integrated
Del: useless -- https://master.php.net/note/delete/106770/useless
Del: bad code -- https://master.php.net/note/delete/106770/bad+code
Del: spam -- https://master.php.net/note/delete/106770/spam
Del: non-english -- https://master.php.net/note/delete/106770/non-english
Del: in docs -- https://master.php.net/note/delete/106770/in+docs
Del: other reasons-- https://master.php.net/note/delete/106770
Reject -- https://master.php.net/note/reject/106770
Search -- https://master.php.net/manage/user-notes.php