Rotating and flattening produces white image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Rotating and flattening produces white image

Post by martinw17 »

I am using ImageMagick 6.3.4 06/01/07 Q16 on Windows.

If I run the following command:
convert test.psd -affine -1,0,0,-1,0,0 -transform rotated.jpg

Then the result is the image rotated (as a jpeg), as expected. However, if I want to flatten the layers, e.g.
convert test.psd -affine -1,0,0,-1,0,0 -transform -flatten rotated-flattened.jpg

then the result is a white image.
This happens regardless of the source format, e.g.
convert test.jpg-affine -1,0,0,-1,0,0 -transform -flatten rotated-flattened.jpg
does the same.

Is this a bug or am I doing something wrong?

Thanks,
Martin
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating and flattening produces white image

Post by anthony »

You rotated the image out of the positive position space! Remember all affine transforms takes into account any negatge offsets the result image may get, though few image formats understand a negative offset. As such saving the roatted image to say JPEG shows the image rotated, but flattening directly does not see a negativally positioned image!

As such no image was in the area when flattened.

You need to junk the image offset using +repage or adjust your affine with an appropriate offset.

For full details see IM examples, Position of Affine Results
http://www.imagemagick.org/Usage/distorts/#affine_pos
Also see, Affine Result Re-Positioning...
http://www.imagemagick.org/Usage/distorts/#affine_repos
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Re: Rotating and flattening produces white image

Post by martinw17 »

Thanks Anthony.
I read through your examples and it makes sense now. In fact, as all I was trying to achieve was rotation, I have switched to using the -rotate option.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating and flattening produces white image

Post by anthony »

It is faster and simplier to use if that is all you want.

If you jkust want to flip or flop the image that is posible too.
See the top of the Image distortion page.
http://www.imagemagick.org/Usage/distorts/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply