Page 1 of 1

TGAs generated from Crazy Bump got vertically flipped after mogrify -resize

Posted: 2016-02-10T10:50:59-07:00
by tdugard
I use ImageMagick to resize a bunch of textures in several formats (.jpg,.tga,.tif,.exr). But i've noticed a strange behavior with TGAs files generated with crazy bump software : the mogrify -resize command flip the result map vertically. With photoshop generated TGAs there is no problem. With an older non-HDR version of ImageMagick (6.9.0-Q16) the TGAs weren't flipped but i need HDR support because i've got full range EXR to resize.

I've tried also the 7.0 beta with the same flipping issue.

I've provided you a Normal Map generated from CrazyBump for you to see the issue : www.transfernow.net/82bml2v0s6ew

Re: TGAs generated from Crazy Bump got vertically flipped after mogrify -resize

Posted: 2016-02-10T11:16:13-07:00
by fmw42
Does it happen if you use convert rather than mogrify?

What is your IM version and platform?

Re: TGAs generated from Crazy Bump got vertically flipped after mogrify -resize

Posted: 2016-02-17T15:33:33-07:00
by Jason S
Steps to reproduce, in 6.9.3-4 (-resize and -annotate are not necessary):

Code: Select all

convert NRM_Map.tga -resize 200x -annotate +20+20 "TGA" temp.tga
convert temp.tga temp.png
temp.tga and temp.png are flipped. It happens if the input and output formats are both TGA, and the input image has top-down orientation. When IM reads a TGA file, it remembers if the image had a "top-down orientation" flag, and it correctly reads such images. When it goes to write the TGA file, it writes the "top-down" flag, but then it writes the image from bottom-up regardless of the flag.

Suggested workaround: -define tga:image-origin=BottomLeft

Since we're on the topic, TGA format also has a right-to-left orientation flag. IM's support for this flag is also buggy, but in a different way: It doesn't even read such files correctly, but it does copy the flag to the output file (if it is also TGA format). I've never seen a right-to-left TGA file in the wild, and I don't think most viewers support it, so no one's likely to notice the problem.

Re: TGAs generated from Crazy Bump got vertically flipped after mogrify -resize

Posted: 2016-03-10T08:24:28-07:00
by Iamiuru
Thank you for the suggested work around. It worked for me.