php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50711 Imagick::distortImage compounds distortion when used iteratively
Submitted: 2010-01-10 10:16 UTC Modified: 2010-01-10 12:13 UTC
From: lee dot traynor at skeptic dot de Assigned:
Status: Not a bug Package: *Graphics related
PHP Version: 5.3.1 OS: Windows XP SP3
Private report: No CVE-ID: None
 [2010-01-10 10:16 UTC] lee dot traynor at skeptic dot de
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-10 12:13 UTC] pajoye@php.net
Report pecl's extension to pecl.php.net
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC