mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-08-16 19:50:46 +03:00
parent
5b1513b84d
commit
672ad87be6
@ -30,10 +30,17 @@ def read_webp_image(image_path):
|
||||
def cache_image(image_path, cache_dir):
|
||||
"""Resize and cache images using gtk library"""
|
||||
ext = os.path.splitext(image_path)[1].lower()
|
||||
if ext == ".webp":
|
||||
pixbuf = read_webp_image(str(image_path))
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(str(image_path))
|
||||
try:
|
||||
if ext == ".webp":
|
||||
pixbuf = read_webp_image(str(image_path))
|
||||
else:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(str(image_path))
|
||||
|
||||
# If image processing failed, create a black placeholder:
|
||||
except GLib.Error:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 1280, 720)
|
||||
pixbuf.fill(0x0)
|
||||
|
||||
aspect_ratio = pixbuf.get_width() / pixbuf.get_height()
|
||||
scaled_width = 240
|
||||
scaled_height = int(scaled_width / aspect_ratio)
|
||||
|
Loading…
Reference in New Issue
Block a user