|
|
""" Computes a squared image based on the favicon to be used as mobile webapp icon.
App Icon should be in PNG format and size of at least 512x512.
If the favicon is an SVG image, it will be skipped and the app_icon will be set to False.
"""
for website in self:
image = ImageProcess(base64.b64decode(website.favicon)) if website.favicon else None
if not (image and image.image):
website.app_icon = False
continue
w, h = image.image.size
square_size = w if w > h else h
image.crop_resize(square_size, square_size)
image.image = image.image.resize((512, 512))
image.operationsCount += 1
website.app_icon = base64.b64encode(image.image_quality(output_format='PNG'))
|
|