Skip to content

Commit

Permalink
Convert profile image to PNG for favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-niles committed May 18, 2024
1 parent e715666 commit 57516d5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/youtube2zim/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from zimscraperlib.download import stream_file
from zimscraperlib.fix_ogvjs_dist import fix_source_dir
from zimscraperlib.i18n import NotFound, get_language_details, setlocale
from zimscraperlib.image.convertion import convert_image
from zimscraperlib.image.presets import WebpHigh
from zimscraperlib.image.probing import get_colors, is_hex_color
from zimscraperlib.image.transformation import resize_image
Expand Down Expand Up @@ -370,7 +371,7 @@ def run(self):
fpath=self.output_dir / self.fname,
name=self.name,
main_page="home.html",
illustration="favicon.jpg",
illustration="favicon.png",
title=self.title,
description=self.description,
long_description=self.long_description, # pyright: ignore[reportArgumentType]
Expand Down Expand Up @@ -853,12 +854,16 @@ def update_metadata(self):
self.main_color = self.main_color or profile_main
self.secondary_color = self.secondary_color or profile_secondary

# convert profile image to png for favicon
png_profile_path = self.build_dir.joinpath("profile.png")
convert_image(self.profile_path, png_profile_path)

resize_image(
self.profile_path,
png_profile_path,
width=48,
height=48,
method="thumbnail",
dst=self.build_dir.joinpath("favicon.jpg"),
dst=self.build_dir.joinpath("favicon.png"),
)

def make_html_files(self, actual_videos_ids):
Expand Down

0 comments on commit 57516d5

Please sign in to comment.