I used python pillow library because i need to convert .ico to .gif
So i used Pillow 6.1.0 ver with Python 3.7.0 I do the following:
from PIL import Image
im = Image.open("a.ico")
im.show()
im.save("a.gif")
.ico file has transparent background
But im.show() loaded Image is black background So finally i got black background .gif file
I want to know how i get transparent .gif conversion files!
im.show()
loaded Image is black background
It is because Image.show()
converts the image to .bmp
(bitmap) before displaying it. And Bitmap in PIL
doesn't supports Alpha (variable Transparency/Opacity). Therefore, the alpha data in your .ico
image gets lost when you try to display the image using Image.show()
.
Solution:- Don't view image containing alpha values using Image.show()
, instead save the image and then view it (via some Image processing package like photoshop etc, or using your OS's builtin image viewer like Photos in Windows 10 ).
I want to know how i get transparent
.gif
conversion files!
.gif
(graphical interchange format) does not support Alpha channel. So, it is not possible for you to convert .ico
file into a .gif
while retaining the transparent regions. Therefore, it is not advised to save an image having Alpha channel to a .gif
, because it ends up having artifacts and would degrade the quality of the original image.
Solution:- I would suggest you to choose a format like .png
or .jp2
, which supports alpha channel. They support a large range of colors too (as opposed to a GIF , which supports only 256 discrete colors ( 8 bit palette )).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.