U
U
un1t2012-01-17 14:21:18
Python
un1t, 2012-01-17 14:21:18

Python convert ico to png while preserving transparency

At the input, an icon with a transparent background - the output is a png with an opaque background. And it is necessary with transparent.
I do something like this:

import Image
…
im = Image.open(f)
im = im.convert("RGBA")
im.save(t, 'png')

This code works for gif, but not for icons. Guess who made the decision?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bagyr, 2012-01-17
@un1t

PIL cannot guess the transparency index of ico.
Solution: im.save(t, 'png', transparency=0) - the index was put down by hand or djangosnippets.org/snippets/1287/ (didn't try the second one).

U
un1t, 2012-01-17
@un1t

Thanks a lot!!! The snippet in the link solved the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question