Skip to content

Conversation

@radarhere
Copy link

Suggestions for python-pillow#6487

Feel free to disagree with any of my rearranging of code.

  • Rather than always defaulting the pixel format to RGBA8888 when saving, use that for RGBA, RGB888 for RGB, I8 for L and IA88 for LA.
  • Rather than writing the thumbnail image to a BytesIO buffer to get the length before writing it, _get_texture_size() can be used to get the length.
  • Comment unused VtfPF enum values. I presume that's the pattern you were going for with the commented values.
  • Removed HEADER_V72 and HEADER_V73. It seems like duplicate code to me, so instead of packing the entire header at one, just pack the HEADER_V70 portion, and then append the rest.
  • Convert to RGBA for low-res DXT1, rather than RGB. I don't imagine there's any reason to abandon the alpha channel
  • Thumbnail does not scale up, so thumb.thumbnail((min(16, width), min(16, height))) can be simplified to thumb.thumbnail((16, 16))
  • DXT1 supports 8-bit alpha, so the CompiledVtfFlags.EIGHTBITALPHA flag can be used there as well
  • Only CompiledVtfFlags.EIGHTBITALPHA for bcn encoding if there is an alpha channel present

@radarhere
Copy link
Author

Cherry-picked into the PR.

@radarhere radarhere closed this May 31, 2025
@radarhere radarhere deleted the vtf_support branch May 31, 2025 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant