Thumbnail background of transparent gif created by PIL/Pillow is not transparent on windows explorer

Viewed 54

I tried convert transparent png to transparent gif (with greenback)

source image

import pathlib
from PIL import Image
import sys
import numpy as np

src = pathlib.Path(sys.argv[0]).with_name('src.png')
dst = src.with_name('dst.gif')
im = Image.open(src)
fill_colors = (200, 170, 200, 0)

bg = Image.new('RGBA', im.size, color=fill_colors)
bg.paste(im, mask=im)

bg = bg.convert('P')
palette = np.array(bg.getpalette(),dtype=np.uint8).reshape((256,3))
bgcolor_idx = np.where(palette==fill_colors[:3])[0][0]
bg.save(dst, transparency=bgcolor_idx)

output

The image is transparent, but the background color is displayed on the thumbnail.

How can fix thumbnails transparent?

It's not a problem an icon cache

0 Answers
Related