Page 1 of 1

Wrong page rotation on Rotate 180 IM: 7.0.4-4

Posted: 2017-01-17T10:08:17-07:00
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

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

Posted: 2017-01-17T10:35:12-07:00
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

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

Posted: 2017-01-17T18:07:26-07:00
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.

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

Posted: 2017-01-18T00:42:54-07:00
by ZpmFred
Thanks for the fast reply and fix.