如何在python中使用S3TC/DXT算法压缩PNG图像?

How to compress PNG image with S3TC/DXT algorithm in python?

我尝试找到使用 python 库的任何 S3TC/DXT 算法压缩图像(以 PNG 为例)的方法。

正如我在 Read-only formats 部分的 Pillow(PIL) 库 DDS 格式中看到的那样。因此 Pillow 不能用于此目的。
在 google 中搜索没有得到肯定的结果。

问题:

可以用python吗?
有人可以向具有此类功能的图书馆提供 link 吗?(已在实践中检查)
DDS 格式对于我的情况不是强制性的。我只需要压缩文件。

PS:

创建纹理以供将来使用是必需的。
库应该支持不同的 algorithms of compression.

您可以使用 Python Wand。在这里,我创建了一个带有洋红色-黄色渐变的伪图像并另存为 DDS:

from wand.image import Image
with Image(width=200, height=80, pseudo='gradient:magenta-yellow') as img: 
   img.save(filename='result.dds') 

或者,如果您想加载 PNG 文件并另存为 DDS:

with Image(filename='input.png') as img: 
   img.save(filename='result.dds')