Wrong page rotation on Rotate 180 IM: 7.0.4-4

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
ZpmFred
Posts: 2
Joined: 2017-01-17T09:49:39-07:00
Authentication code: 1151

Wrong page rotation on Rotate 180 IM: 7.0.4-4

Post by ZpmFred »

Hello,

I've got a problem when rotating an image by 180°the image effectively rotate by 180°but the Page does not rotate by 180°, instead it rotate by 90°.

After some investigation in the source code I think that I found the source of the problem.
On a rotation of 180° the function that perform the actual rotation is "IntegralRotateImage" MagicCore/shear.c.
A rotation of 180° is transformed in a "rotation" of "2" when passed to "IntegralRotateImage".
In the body of the function there is a switch on the variable "rotation", in the case where "rotation == 2" we find the following code

Code: Select all

case 2:
    {
      register ssize_t
        y;
      /*
        Rotate 180 degrees.
      */
So we are in fact in the right case for our value of "rotation".
Here come the problem at the end of the case we find the following code:

Code: Select all

      Swap(page.width,page.height);
      Swap(page.x,page.y);
But when rotating an image by 180° you don't need to swap the width and the height ... this is right on an 90° rotation.

I hope that this will be able to help you solve the problem :D
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Wrong page rotation on Rotate 180 IM: 7.0.4-4

Post by GeeMack »

ZpmFred wrote: 2017-01-17T10:08:17-07:00I've got a problem when rotating an image by 180°the image effectively rotate by 180°but the Page does not rotate by 180°, instead it rotate by 90°
I'm using IM 7.0.4-4 HDRI on Windows 10 64, and this issue appears here, too. This command creates a 360x240 blue rectangle, then rotates it 180 degrees...

Code: Select all

magick xc:blue[360x240!] -rotate 180 info:
The output of the command shows it rotated the image 180 degrees, while the page info has rotated 90 degrees and shifted w/2 to the left. Here's the output...

Code: Select all

xc:blue[360x240!] XC 360x240 240x360-120+0 16-bit sRGB 0.016u 0:00.016
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Wrong page rotation on Rotate 180 IM: 7.0.4-4

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.
ZpmFred
Posts: 2
Joined: 2017-01-17T09:49:39-07:00
Authentication code: 1151

Re: Wrong page rotation on Rotate 180 IM: 7.0.4-4

Post by ZpmFred »

Thanks for the fast reply and fix.
Post Reply