php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64472 Flip-flipped argument handling not documented
Submitted: 2013-03-20 21:32 UTC Modified: 2015-04-01 17:04 UTC
From: psmith at gurutechnologies dot net Assigned: danack (profile)
Status: Closed Package: imagick (PECL)
PHP Version: Irrelevant OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: psmith at gurutechnologies dot net
New email:
PHP Version: OS:

 

 [2013-03-20 21:32 UTC] psmith at gurutechnologies dot net
Description:
------------
---
From manual page: http://www.php.net/imagick.extentimage
---
Undocumented flip-flop in argument interpretation on Imagick::extentImage(int $width, int $height, int $x, int $y):

Prior to ImageMagick 6.5.7-8 (1623), $x was positive when shifting to the left and negative when shifting to the right, and $y was positive when shifting an image up and negative when shifting an image down.

Somewhere betwen ImageMagick 6.3.7 (1591) and ImageMagick 6.5.7-8 (1623), the axes of $x and $y were flipped, so that $x was negative when shifting to the left and positive when shifting to the right, and $y was negative when shifting an image up and positive when shifting an image down.

Somewhere between ImageMagick 6.5.7-8 (1623) and ImageMagick 6.6.9-7 (1641), the axes of $x and $y were flipped back to pre-ImageMagick 6.5.7-8 (1623) functionality.

Test script:
---------------
<?php
$imagick = new Imagick();
$imagick_version = $imagick->getVersion();
if($imagick_version['versionNumber'] == 1623)
  $pos_factor = 1;
else
  $pos_factor = -1;

$imagick->readImage($path_to_some_image_to_center);
$imagick->resizeImage($new_width, $new_height, imagick::FILTER_LANCZOS, 1);
$imagick->setImageBackgroundColor(new ImagickPixel('#000000'));
$imagick->extentImage($max_width, $max_height, $pos_factor * ($max_width - $new_width) / 2, $pos_factor * ($max_height - $new_height) / 2);
?>

Expected result:
----------------
Using the above code to scale and fit image, centered, into an incongruent container should result in a properly centered image.

Actual result:
--------------
If $x and $y do not use the signs (positive or negative) expected by the installed version of Imagick, the image is shifted in the wrong direction!  This should be noted in the documentation as a warning.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-01 17:04 UTC] danack@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: danack
 [2015-04-01 17:04 UTC] danack@php.net
Added to manual, it will be there after the next build.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 20:01:35 2025 UTC