GithubHelp home page GithubHelp logo

Comments (6)

Yay295 avatar Yay295 commented on May 25, 2024

Pillow 6.2.2 was released more than four years ago. Would you be able to find a newer version of Pillow that works as expected?

I looked through the history of the TGA image plugin since 6.2.2 and didn't notice anything, so it may a change to some other file that caused this.

from pillow.

radarhere avatar radarhere commented on May 25, 2024

The demo code that the user provided doesn't use the TGA format, so I think this is just about DDS. I think Pillow 8.2.0 would be the last version that gives the result you want, and that the change came from #5383.

If I manually eyedrop the top left corner in Gimp, I get (192, 192, 192).
If I convert your image to a PNG using ImageMagick and get the top left pixel using Pillow, I get (192, 192, 192, 0)

I suspect PVRTextool only works on Windows. Is that the case?

Could you attach a copy of what you think the image should look like, in a common format like PNG?

This is what Pillow thinks the image should look like, ImageMagick agrees, and so does https://imagetostl.com/view-dds-online.

out

I'm not convinced that Pillow is behaving incorrectly.

from pillow.

7ippo avatar 7ippo commented on May 25, 2024

Thanks for the reply. Yes It is more likely related to the DDS plugin. And here is the png I got from PVRTextool's File - Save Image function and this what I expect.

water6_1x4
The PNG format file

This is also what I see from PVRTextool. I'm not sure if PVRTexTool only works on Windows, but I usually use it to view texture data.

POPO-20240417-182502
What I see from PVRTextool, including channel's information and raw texel data.

from pillow.

radarhere avatar radarhere commented on May 25, 2024

Thanks for the image.

My conclusion from my previous comment is that Pillow is not incorrect, and nothing needs to be changed here.

Here's some more evidence to consider

If you would like Pillow to create your version of the image from A8R8G8B8 images, you could move the channels around only for those images like so

from PIL import Image
with Image.open("water6_1x4.dds") as img:
    if img.tile[-1][-1] == (32, (16711680, 65280, 255, 4278190080)):
        r, g, b, a = img.split()
        img = Image.merge("RGBA", (g, b, a, r))
    img.save("out.png")

from pillow.

7ippo avatar 7ippo commented on May 25, 2024

Thank you for your patient explanation. After a careful troubleshooting process lasting for almost two days, we have basically confirmed that the issue is caused by a bug or bizarre behavior in PVRTextool related to uncompressed DDS textures.

We discovered that, interestingly, the rendering error in our game was not caused by Pillow's DDS reading. Instead, it was precisely due to a brief usage of a newer version of the PVRTextool(v5.5.0) during the update of our cacheserver project, for compressing from DDS to ASTC, which led to the issue. This will turn the texture into yellow(different channel data), just like the png file I uploaded above. But the previous version of PVRTextool(v4.20) will not encounter this issue. Pillow won't either. And we confirmed that if the uncompressed DDS textures are preprocessed by using Pillow they will render correctly in the game.

Viewing the uncompressed DDS textures using tools like Nvidia Texture Tool shows different results compared to PVRTextool.

Snipaste_2024-04-19_11-40-49

So it seems that there might be an issue with how PVRTextool handles uncompressed DDS textures, causing problems when viewing or compressing using command-line tools.

from pillow.

radarhere avatar radarhere commented on May 25, 2024

Thanks for figuring that out. It may be helpful to anyone else encountering this in the future.

from pillow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.