mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-09-11 16:26:14 +03:00
parent
5b1513b84d
commit
672ad87be6
@ -30,10 +30,17 @@ def read_webp_image(image_path):
|
|||||||
def cache_image(image_path, cache_dir):
|
def cache_image(image_path, cache_dir):
|
||||||
"""Resize and cache images using gtk library"""
|
"""Resize and cache images using gtk library"""
|
||||||
ext = os.path.splitext(image_path)[1].lower()
|
ext = os.path.splitext(image_path)[1].lower()
|
||||||
if ext == ".webp":
|
try:
|
||||||
pixbuf = read_webp_image(str(image_path))
|
if ext == ".webp":
|
||||||
else:
|
pixbuf = read_webp_image(str(image_path))
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(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()
|
aspect_ratio = pixbuf.get_width() / pixbuf.get_height()
|
||||||
scaled_width = 240
|
scaled_width = 240
|
||||||
scaled_height = int(scaled_width / aspect_ratio)
|
scaled_height = int(scaled_width / aspect_ratio)
|
||||||
|
Loading…
Reference in New Issue
Block a user