
我有幾張舊的 BPG 編碼圖片。由於 PNG 被用作輸入格式,因此它們有一個(空)alpha 通道,因此無法由較新的 libbpg 解碼:
版本0.9.4:
- 修改了 alpha 平面編碼以允許漸進式顯示和流式編碼。此變更不相容,因此無法解碼包含先前版本格式的 Alpha 的圖像。
我不需要這個 Alpha 通道。如何無損地將它們轉換為新的 BPG 格式?
答案1
使用我的工具從其中刪除 Alpha 通道:https://gist.github.com/vi/9297cd5bf80f0b34e8a2
它從舊的 BPG 檔案中刪除 Alpha 通道,使它們可以由較新的 BPG 解碼器進行解碼。
$ bpgdec -i test.bpg
size=1606x1263 color_space=YCbCr alpha=1 premul=0 format=4:2:0 limited_range=0 bit_depth=8 animation=0
$ bpgdec test.bpg
Could not decode image
$ bpg93_remove_alpha.pl < test.bpg > test.noa.bpg
magic: 425047FB
PixelFormat: 1 alpha: 1 bitdepth: 8
ColorSpace: 0 ExtPresent: 0 Alpha2: 0 LimitedRange: 0 ReservedZero: 0
Width: 1606 Height: 1263
Picture data length: 81969
Alpha data length: 239
$ bpgdec -i test.noa.bpg
size=1606x1263 color_space=YCbCr format=4:2:0 limited_range=0 bit_depth=8 animation=0
$ bpgdec test.noa.bpg
$