diff --git a/src/core/widgets/image.py b/src/core/widgets/image.py index 2334536..d780012 100644 --- a/src/core/widgets/image.py +++ b/src/core/widgets/image.py @@ -15,7 +15,7 @@ from .image_view import ImageView, PImage class Image(Gtk.EventBox): - def __init__(self, path = None): + def __init__(self, path: str): super(Image, self).__init__() self._thumbnail_with = settings.get_thumbnail_with() @@ -66,10 +66,13 @@ class Image(Gtk.EventBox): if path.endswith(".gif"): pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(path).get_static_image() - if not pixbuf: - try: - pixbuf = Gtk.Image.new_from_file(path).get_pixbuf() - except Exception: - pixbuf = Gtk.Image.new_from_resource(path).get_pixbuf() + if pixbuf: + return pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default + + try: + return GdkPixbuf.Pixbuf.new_from_file_at_scale(path, w, h, True) + except Exception: + return Gtk.Image.new_from_resource(path) \ + .get_pixbuf() \ + .scale_simple(w, h, 2) # 2 = BILINEAR and is best by default - return pixbuf.scale_simple(w, h, 2) # 2 = BILINEAR and is best by default