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

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
tdugard
Posts: 1
Joined: 2016-02-10T10:07:07-07:00
Authentication code: 1151

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Does it happen if you use convert rather than mogrify?

What is your IM version and platform?
Jason S
Posts: 103
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

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

Post 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.
Iamiuru
Posts: 3
Joined: 2012-12-12T13:12:11-07:00
Authentication code: 6789

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

Post by Iamiuru »

Thank you for the suggested work around. It worked for me.
Post Reply