You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Transparent images don't seem to be handled correctly #9473
I'm using Pillow 12.1.1, Python 3.14.
I was trying to do some image manipulation steps with some VTF textures. I noticed that some of the transparent ones had erroneous results. For example, this is just reading the raw pixel buffer with Image.frombytes() and showing it:
Even when I tried to export the texture to TGA format and open it, Pillow was still showing the same result. However, the texture above was displayed fine when I was using RGB mode.
I have attached the .tga image but I have to add a .txt suffix so github can accept to upload it. (Change the extension to .tga if you want to view it)
Thanks for the TGA file. I can replicate the problem there.
I'm slightly confused about your VTF problem though. It looks like you've only uploaded the TGA file and two PNGs, so I don't see how I could replicate anything.
The VTF (Valve Texture Format) is basically a container for various compressed/uncompressed image formats and their mipmaps. I want to reduce the size of it by resizing then compressing the underlying image if the format is not compressed. My plan was parsing the VTF and get the raw RGB(A) pixel data, converting it into a pillow Image with Image.frombytes() then do the processing.
The PNG on the left was exported (not exactly, more like copy pasted) by a known good VTF editor from a VTF using DXT5 image format, which supports transparency. The right PNG was generated with Image.show() right after reading the raw data. When converting the Image to RGB mode, pillow showed it fine so I believe there's a problem with transparency handling.
At first when i thought it was a problem with VTF parsing so i dumped the raw data and did a binary comparison with an image exported by the editor. It was a BMP file, not TGA, but judging from the size, I believe they are just some headers + raw pixel data.
I stripped the BMP header to make the comparison easier. The binaries were identical so I think there was nothing wrong with VTF parsing.
The raw pixel data in the TGA I attached should be the starting point to replicate the problem. I also attached the VTF and raw image data in RGBA8888 format if that helps.
changed the title [-]Transparent images don't seems to be handled correctly[/-][+]Transparent images don't seem to be handled correctly[/+]on Mar 20, 2026
Activity
radarhere commentedon Mar 19, 2026
Thanks for the TGA file. I can replicate the problem there.
I'm slightly confused about your VTF problem though. It looks like you've only uploaded the TGA file and two PNGs, so I don't see how I could replicate anything.
long0900 commentedon Mar 20, 2026
Lemme try to explain the problem a bit more.
The VTF (Valve Texture Format) is basically a container for various compressed/uncompressed image formats and their mipmaps. I want to reduce the size of it by resizing then compressing the underlying image if the format is not compressed. My plan was parsing the VTF and get the raw RGB(A) pixel data, converting it into a pillow Image with
Image.frombytes()then do the processing.The PNG on the left was exported (not exactly, more like copy pasted) by a known good VTF editor from a VTF using DXT5 image format, which supports transparency. The right PNG was generated with
Image.show()right after reading the raw data. When converting the Image to RGB mode, pillow showed it fine so I believe there's a problem with transparency handling.At first when i thought it was a problem with VTF parsing so i dumped the raw data and did a binary comparison with an image exported by the editor. It was a BMP file, not TGA, but judging from the size, I believe they are just some headers + raw pixel data.
I stripped the BMP header to make the comparison easier. The binaries were identical so I think there was nothing wrong with VTF parsing.
The raw pixel data in the TGA I attached should be the starting point to replicate the problem. I also attached the VTF and raw image data in RGBA8888 format if that helps.
door_a.vtf.txt
door_a.raw.txt
radarhere commentedon Mar 20, 2026
I've created #9478 to resolve this. With that,
gives me
[-]Transparent images don't seems to be handled correctly[/-][+]Transparent images don't seem to be handled correctly[/+]