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
TGAs generated from Crazy Bump got vertically flipped after mogrify -resize
- 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
Does it happen if you use convert rather than mogrify?
What is your IM version and platform?
What is your IM version and platform?
Re: TGAs generated from Crazy Bump got vertically flipped after mogrify -resize
Steps to reproduce, in 6.9.3-4 (-resize and -annotate are not necessary):
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.
Code: Select all
convert NRM_Map.tga -resize 200x -annotate +20+20 "TGA" temp.tga
convert temp.tga temp.png
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
Thank you for the suggested work around. It worked for me.