proper handy avatar size on hidpi

parent 9e1b1ebc
Pipeline #229229 failed with stage
in 9 minutes and 43 seconds
......@@ -24,7 +24,7 @@ def get_favicon(link, favicon_path):
'size': -1
}
for e in favicon_els:
if candidate['size'] >= 32:
if candidate['size'] >= 100:
break
if 'rel' in e.attrib.keys():
size = 0
......
......@@ -13,14 +13,15 @@ def make_thumb(path, width: int, height: int = 1000) -> str:
return None
if not isinstance(path, Path):
path = Path(path)
dest = thumbs_cache_path.joinpath(f'{width}x{height}_{path.name}')
dest = thumbs_cache_path.joinpath(f'{width}x{height}_{path.name}_v2')
if dest.is_file():
return str(dest)
try:
with Image.open(path) as thumb:
thumb = Image.open(path)
thumb.thumbnail((width, height), Image.ANTIALIAS)
thumb.save(dest, 'PNG')
thumb.resize((width, height)).save(dest, 'PNG')
# thumb.thumbnail((width, height), Image.ANTIALIAS)
# thumb.save(dest, 'PNG')
return str(dest)
except IOError:
print(f'Error creating thumbnail for image `{path}`')
......
......@@ -233,31 +233,6 @@ class Feed:
get_favicon(self.items[0].link, self.favicon_path)
except Exception:
print('No favicon')
if isfile(self.favicon_path):
try:
self._resize_favicon(self.favicon_path)
except Exception:
print(_(
'Error resizing favicon for feed {0}. '
'Probably not an image.\n'
'Trying downloading favicon from an article.'
).format(self.title))
try:
get_favicon(self.items[0].link, self.favicon_path)
self._resize_favicon(self.favicon_path)
except Exception:
print(_(
'Error resizing favicon from article for feed {0}.\n'
'Deleting invalid favicon.'
).format(self.title))
remove(self.favicon_path)
def _resize_favicon(self, img_path):
favicon = Image.open(img_path)
if favicon.width != 32:
favicon = favicon.resize((32, 32), Image.BILINEAR)
favicon.save(self.favicon_path, 'PNG')
favicon.close()
def __repr__(self):
return f'Feed Object `{self.title}`; {len(self.items)} items'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment