Commit 8b7d7a8b authored by Suhas's avatar Suhas Committed by Alexandru Băluț

medialibrary: Create the image thumbnail out of the image

Previously, thumbnails for images were simply
falling back to image-x-generic

Fixes T7668
Reviewed-by: Alexandru Băluț's avatarAlex Băluț <alexandru.balut@gmail.com>
Differential Revision: https://phabricator.freedesktop.org/D1618
parent 67794ff6
......@@ -213,7 +213,22 @@ class AssetThumbnail(Loggable):
small_thumb, large_thumb = self.__get_thumbnails_from_xdg_cache(real_uri)
if not small_thumb:
if self.__asset.is_image():
small_thumb, large_thumb = self.__get_icons("image-x-generic")
path = Gst.uri_get_location(real_uri)
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(path)
width = pixbuf.props.width
height = pixbuf.props.height
small_thumb = pixbuf.scale_simple(
SMALL_THUMB_WIDTH,
SMALL_THUMB_WIDTH * height / width,
GdkPixbuf.InterpType.BILINEAR)
large_thumb = pixbuf.scale_simple(
LARGE_THUMB_WIDTH,
LARGE_THUMB_WIDTH * height / width,
GdkPixbuf.InterpType.BILINEAR)
except GLib.Error as error:
self.debug("Failed loading thumbnail because: %s", error)
small_thumb, large_thumb = self.__get_icons("image-x-generic")
else:
# Build or reuse a ThumbnailCache.
thumb_cache = ThumbnailCache.get(self.__asset)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment