Hi, I’m trying to convert a KTX image to the PNG format with the PVRTexTool. When I use the GUI tool, open up the KTX file, and click save as image, the image is converted perfectly. However, this is too slow. I have thousands of KTX images to convert to PNG and so I turned to the PVRTexToolCLI. Except, it seems as though the CLI doesn’t work for some KTXs.
For example when I run this command, PVRTexToolCLI -i input.ktx -d output.png -f r8g8b8a8
I get the error Error: Unable to save texture as requested format, please check the format being used is supported.
I’ve tried the same command with the attached .ktx file with the same PVRTexToolCLI version (v4.24.0 Build 20.1@5740574) but it works fine for me.
Could you specify what OS are you on? It might be an OS dependant issue.
In case you’re on Windows, I can give you the latest internal PVRTexTool version. I tried and works fine as well, it might be a bug already fixed. I’d give you this version through support (I can see you also submitted a ticket in https://pvrsupport.imgtec.com).
I reinstalled the package and it’s finally outputting the PNG. Except, the PNG has black where alpha should be. The PNG outputted from the GUI doesn’t have this problem though. Did you have this issue when decompressing my KTX?
The Tools team verified this issue is fixed in the internal version. I already answered the ticket you sent through our support web (https://pvrsupport.imgtec.com) with instructions for downloading the lastest MacOS internal version.
Please let me know if you experience any other issues.
Actually, I spoke too soon. It looks like the color is still off. Here’s the intended PNG generated by the old version of the GUI and here’s the PNG generated by the internal version of the CLI. The GUI PNG also looks like the KTX when viewed by the Preview default application on macOS.
After reviewing with the Tools Team, this issue is due to linear and sRGB color space differences. PVRTexTool 4.24 shows images without any gamma correction as the Preview default application on MacOS does. The Internal Version CLI applies gamma correction to the results, and also the Internal Version GUI now applies gamma correction to preview images, giving place to a brighter preview. Apologies for all the confusion.
I figured that might be the situation. In that case, I think I have found another bug for you. I can’t seem to change the format to lRGB with the Internal CLI. For example, this command produces the same sRGB PNG as before. PVRTexToolCLI -i input.ktx -d output.png -f r8g8b8a8,UBN,lRGB
After consulting with the Tools Team, in the command “-i input.ktx -d output.png -f FRMT”:
The “-d” part of the command means decompress and implies saving the texture to an image file like PNG, JPG or BMP, which generally expect RGBA8888 and sRGB colour space.
The “-f FRMT” part transcodes the input to format FRMT before being saved.
However image files like PNG are always transcoded to RGBA8888 sRGB before being saved (you’d need a different container like .pvr or .ktx to store the texture in its native format). This means that -f r8g8b8a8, -f r8g8b8a8,UBN,lRGB and -f r8g8b8a8,UBN,sRGB produce the same PNG file.
You can use the -ics “input color space” parameter available for the Internal Version. It will force CLI to treat input texture as sRGB. Combined with the format option, no colour space conversion will be done when saving to PNG, producing the results you expect: PVRTexToolCLI -i input.ktx -ics sRGB -d linear.png -f r8g8b8a8,UBN,sRGB