I am new to working with favicons, and am having trouble understanding formatting. For 2 examples: I pull the favicon from google.com and noticed that the shape is 16x16x4. Why not 16x16x3?
For whatsapp.com, it is 194x194, and when I try to display the image, it looks corrupted, and different when compared to jupyter notebook's build in tool for displaying images
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)
I would expect the image shape to be 16x16x3, and I would expect the image to be rendered the same way. Is there something obvious I am missing?
The fourth channel would be alpha, which contain transparancy information. If you read your images like this,
im = Image.open(host + ".favicon.ico").convert('RGBA')
it should be displayed properly.