NickHugi / PyKotor

A Python library that can read and modify most file formats used by the game Knights of the Old Republic and its sequel.
GNU Lesser General Public License v3.0
11 stars 3 forks source link

PyKotor - Use pillow by default if available. #87

Closed th3w1zard1 closed 5 months ago

th3w1zard1 commented 5 months ago

Stream.py is one of the biggest bottlenecks of this project. While I don't know how to fix it (the last 4 prs addressing it did not have drastic results), this pr at least fixes the problem in KOTOR's biggest files: TGA textures.

Since most of the tools use Pillow anyway it doesn't make sense not to use it if available. This PR will check if pillow can be imported, and if so will use Pillow to load TGA files. If it's not available, fall back to original custom logic. This ensures we don't add unnecessary dependencies to PyKotor.