为什么网站图标形状为 16x16x4,whatsapp 图标有什么问题?

Why is favicon shape 16x16x4 and what is wrong with the whatsapp favicon?

我刚开始使用网站图标,无法理解格式。对于 2 个示例: 我从 google.com 中拉出图标并注意到形状是 16x16x4。为什么不是 16x16x3?

对于 whatsapp.com,它是 194x194,当我尝试显示图像时,它看起来已损坏,并且与 jupyter notebook 的内置图像显示工具相比有所不同

from PIL import Image
import requests
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import Image as show_Image 


def get_favicon_save_load_display(host):
    example = requests.get( "https://" +  host + '/favicon.ico')
    with open(host + ".favicon.ico", 'wb') as f:
        f.write(example.content)
    im = Image.open(host + ".favicon.ico")
    np_im = np.array(im)
    print("The image shape is: ", np_im.shape)
    plt.imshow(np_im) 
    plt.show()

get_favicon_save_load_display('google.com')
get_favicon_save_load_display('whatsapp.com')

example = requests.get('https://whatsapp.com/favicon.ico')
show_Image(example.content)

我希望图像形状为 16x16x3,并且我希望图像以相同的方式呈现。有什么明显的我想念的吗?

第四个通道是 alpha,它包含透明度信息。如果你这样阅读你的图片,

im = Image.open(host + ".favicon.ico").convert('RGBA')

应该可以正常显示。