![](/img/trans.png)
[英]How to compress PNG image fetched from url without changing it's dimenstions
[英]How to compress PNG image with S3TC/DXT algorithm in python?
我嘗試找到使用python庫使用任何S3TC / DXT算法壓縮圖像的方法(以PNG為例)。
正如我在“ Read-only formats
部分的Pillow(PIL)庫DDS格式中看到的那樣。 因此,枕頭不能用於此目的。
在谷歌搜索沒有得到積極的結果。
可以用python做嗎?
有人可以提供具有這種功能的庫的鏈接嗎(在實踐中檢查)
對於我的情況,DDS格式不是強制性的。 我只需要壓縮文件。
創建紋理以供將來使用是必需的。
庫應支持不同的壓縮算法。
您可以使用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')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.