Closed Bxaa closed 3 years ago
What do you mean by "wrong" orient exactly?
As far as I can tell, that image loads correctly with DirectXTex.
Metadata in the TGA is:
TGA
ColorMap Type = 0
ImageType = 2 TGA_TRUECOLOR
ColorMap First = 0
ColorMap Length = 0
ColorMap Entry Size = 0
Origin 0, 0
Size: 1024 by 256
Bits Per Pixel 32
Image descriptor 08
Attributes 8
ExtensionOffset = 0
DeveloperOffset = 0
Signature= TRUEVISION-XFILE.
Hi,
So...Input tga orientation: BottomLeft (Orientation: TopLeft by default? = 0?) Example: Texconv -ft tga -f b5g5r5a1_unorm -o "test.tga" -y "test.tga" now orient tag is TopLeft
Most graphic\image tools and some old game engines use it and you get a reversed image
It would be nice if you didn't need to use third-party tools for it Texconv -resetorient\setorient 'value'\preserveorient (preserveorient while resizing and some operations that require image rewriting) args (resetorient and setorient without any convertion and overwriting original image file) Also: preserveorient by default is enabled (that would be right)
I am doing remasters of old games and therefore this is a rather important aspect. Example: https://www.nexusmods.com/starwarsjediknightjediacademy/mods/23 https://www.nexusmods.com/jediknight2/mods/7 https://www.nexusmods.com/witcher/mods/930 https://www.nexusmods.com/morrowind/mods/49796 https://www.nexusmods.com/startrekeliteforceII/mods/438 https://www.nexusmods.com/heavymetalfakk2/mods/1 https://www.nexusmods.com/gothic3/mods/16 Yep...some textures require orient tag (for targa)
Sorry my english and thx for texconv, I hope you know what I mean :) Having to work with thousands of files, so that would be a useful feature (reset\set orient) Yes, it is a specific, but I hope if you have time you can add it At current time i use image magick legacy convert tool (convert -auto-orient) but it completely break some old tga :( Seems to be image magick convert change wrong metadata param for some old tga's while it reset orient (so it not solution) The interesting thing is that there is not a single CLI tool for it (at least I do not know)
(This is image info for jediacademy.tga, Original orient tag = BottomLeft)
Filename: jediacademy.tga Format: TGA (Truevision Targa image) Class: DirectClass Geometry: 1024x256+0+0 Units: Undefined Colorspace: sRGB Type: TrueColorAlpha Base type: Undefined Endianness: Undefined Depth: 8-bit Channel depth: Red: 8-bit Green: 8-bit Blue: 8-bit Alpha: 8-bit Channel statistics: Pixels: 262144 Red: min: 0 (0) max: 252 (0.988235) mean: 36.7095 (0.143959) median: 1 (0.00392157) standard deviation: 49.7467 (0.195085) kurtosis: 1.90575 skewness: 1.5863 entropy: 0.560208 Green: min: 0 (0) max: 251 (0.984314) mean: 51.8097 (0.203175) median: 1 (0.00392157) standard deviation: 63.7955 (0.250179) kurtosis: -0.334483 skewness: 0.954663 entropy: 0.584094 Blue: min: 9 (0.0352941) max: 252 (0.988235) mean: 90.1958 (0.353709) median: 42 (0.164706) standard deviation: 64.0166 (0.251045) kurtosis: -0.652573 skewness: 0.830367 entropy: 0.860909 Alpha: min: 0 (0) max: 255 (1) mean: 157.861 (0.619061) median: 255 (1) standard deviation: 117.27 (0.459882) kurtosis: -1.63543 skewness: -0.52476 entropy: 0.309885 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 84.1439 (0.329976) median: 74.75 (0.293137) standard deviation: 73.7072 (0.289048) kurtosis: -0.809419 skewness: 0.809356 entropy: 0.578774 Alpha: srgba(172,196,229,0) #ACC4E500 Rendering intent: Perceptual Gamma: 0.454545 Chromaticity: red primary: (0.64,0.33) green primary: (0.3,0.6) blue primary: (0.15,0.06) white point: (0.3127,0.329) Matte color: grey74 Background color: white Border color: srgb(223,223,223) Transparent color: none Interlace: None Intensity: Undefined Compose: Over Page geometry: 1024x256+0+0 Dispose: Undefined Iterations: 0 Compression: None Orientation: BottomLeft <<<<---(!) Properties: date:create: 2021-10-07T14:45:29+00:00 date:modify: 2003-07-11T05:49:44+00:00 signature: ba8b5401030007432adde48900c88f630c88bc59bca9128975d74ba16afcf6ba Artifacts: verbose: true Tainted: False Filesize: 1048620B Number pixels: 262144
Old tga: https://drive.google.com/file/d/13UXmGEuvgyk4jmOi7QRYbtQmBvQNhbKF/view?usp=sharing
Thanks for the clarification.
First, the TGA codec used by DirectXTex is 'hand-rolled'. It 's not part of WIC, so it doesn't have any formal EXIF or other metadata support beyond what I've implemented.
As such, I don't know what field of metadata in the file format is being interpreted as Orientation by the tool you are using. My guess is that it's TGA_HEADER.bDescriptor
where the 4th and 5th bit indicate inverting X & Y. My reader respects these bits, but my writer always uses INVERTY
.
In other words: Just passing the TGA through texconv will already "reorient" the TGA to always use INVERTY.
Thx for answer
To exif: EXIF tag table (JPG, TIFF, PNG, JP2, PGF, MIFF, HDP, PSP, XCF) https://exiftool.org/TagNames/EXIF.html
Hi, walbourn Is it possible to add arg like -auto_orient to fix wrong image orient Yes, it can be done via -flip or else, but some image maybe correct orient (massive bach conversion) Need to reset it in EXIF and auto flip image if orient set to 'flip' (Actual for old targa formats)
Wrong tag https://drive.google.com/file/d/1qBLxZdBfiq2RFV3ayfuuKc8r5Csd0yXd/view?usp=sharing