|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-01-10 12:13 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ When used ieteratively, imagick:distortImage compounds the distortion on the image from one image to the next. Reproduce code: --------------- --- From manual page: function.imagick-distortimage --- <?php # $grfile is a panoramic image; $incr is the displacement in pixels/interation $grfile = "Canadas.png"; $incr = 10; # For some strange reason, "new" requires the tiemzone to be set date_default_timezone_set ("Europe/Berlin"); $imsrc = new Imagick ($grfile); $srcwidth = $imsrc->getImageWidth (); $srcheight = $imsrc->getImageHeight (); $image_type = $imsrc->getImageFormat (); $subdir = substr ($grfile, 0, strpos ($grfile, ".")); if (!is_dir ($subdir)) mkdir ($subdir); $aspectratio = 4/3; $destwidth = floor ($srcheight * $aspectratio); $imax = ceil ($srcwidth - $destwidth) / $incr; $dx = $dy = -0.02; $distort = array (0.0, 0.0, $dx, 1 - $dx * $aspectratio, 0.0, 0.0, $dy, 1 - $dy); for ($i = 0; $i < $imax; $i++) { set_time_limit (10); $imdest = $imsrc->clone (); $file_dest = $subdir . "\\" . sprintf ("%04u", $i) . "." . $image_type; $start = round ($i * $incr); $imdest = $imsrc->clone (); $imdest->cropImage ($destwidth, $srcheight, $start, 0); $imdest->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_GRAY); $imdest->distortImage (imagick::DISTORTION_BARREL, $distort, true); $imdest->writeImage ($file_dest); $imdest->destroy (); } $imsrc->destroy (); ?> Expected result: ---------------- A series of images with identical barrel distortions. Actual result: -------------- A series of images with the distortion increasing from one image to the next.