Fixed webp display, added scroll functionality, cleanup

This commit is contained in:
2023-04-28 19:40:16 -05:00
parent d2c8c1a426
commit 7d30a678ca
5 changed files with 24 additions and 11 deletions

View File

@@ -42,7 +42,6 @@ class ImageView(ImageViewMixin, Gtk.Image):
def _setup_styling(self):
...
def _setup_signals(self):
...
@@ -106,19 +105,15 @@ class ImageView(ImageViewMixin, Gtk.Image):
self.work_pixbuff = Gtk.Image.new_from_resource(path).get_pixbuf()
def set_as_webp(self, path):
w = settings.get_thumbnail_with()
h = settings.get_thumbnail_height()
self.work_pixbuff = self.image2pixbuf(path, w, h)
self.work_pixbuff = self.image2pixbuf(path)
@staticmethod
def image2pixbuf(path, _w, _h):
def image2pixbuf(path):
"""Convert Pillow image to GdkPixbuf"""
im = PImage.open(path)
data = im.tobytes()
data = Bytes.new(data)
w, h = im.size
pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
return GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
False, 8, w, h, w * 3)
return pixbuf.scale_simple(_w, _h, 2) # 2 = BILINEAR and is best by default