note 124851 added to imagick.nextimage
| From: | simonjjarrett at gmail dot com | Date: | Tue, 24 Mar 2020 13:02:55 +0000 |
| Subject: | note 124851 added to imagick.nextimage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214372@lists.php.net to get a copy of this message | ||
The following function applies a callback to each image in an Imagick object.
<?php
function imagickMap($callback, $im)
{
$im->setFirstIterator();
do
{
$callback($im);
}
while ( $im->nextImage() );
}
?>
E.g. to convert a series of images to grayscale:
<?php
imagickMap(
function($im)
{
$im->setImageType(Imagick::IMGTYPE_GRAYSCALEMATTE);
},
$im
);
?>
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.195 (proxied: 81.109.86.207)
----
Manual Page -- http://php.net/manual/en/imagick.nextimage.php
Edit -- https://master.php.net/note/edit/124851
Del: integrated -- https://master.php.net/note/delete/124851/integrated
Del: useless -- https://master.php.net/note/delete/124851/useless
Del: bad code -- https://master.php.net/note/delete/124851/bad+code
Del: spam -- https://master.php.net/note/delete/124851/spam
Del: non-english -- https://master.php.net/note/delete/124851/non-english
Del: in docs -- https://master.php.net/note/delete/124851/in+docs
Del: other reasons-- https://master.php.net/note/delete/124851
Reject -- https://master.php.net/note/reject/124851
Search -- https://master.php.net/manage/user-notes.php