From 6613f3f05a548bb3b91d03becbaa694379ecdde4 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 13 Feb 2019 01:37:11 +0100 Subject: Respect EXIF orientation tag fixes #522 --- .../content_item_widget_factory.vala | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'main/src') diff --git a/main/src/ui/conversation_summary/content_item_widget_factory.vala b/main/src/ui/conversation_summary/content_item_widget_factory.vala index 4a625cc5..0bd763ec 100644 --- a/main/src/ui/conversation_summary/content_item_widget_factory.vala +++ b/main/src/ui/conversation_summary/content_item_widget_factory.vala @@ -107,11 +107,17 @@ public class FileItemWidgetGenerator : WidgetGenerator, Object { public Object get_widget(ContentItem item) { FileItem file_item = item as FileItem; FileTransfer transfer = file_item.file_transfer; - if (transfer.mime_type != null && transfer.mime_type.has_prefix("image")) { - return getImageWidget(transfer); - } else { - return getDefaultWidget(transfer); + + if (transfer.mime_type != null) { + foreach (PixbufFormat pixbuf_format in Pixbuf.get_formats()) { + foreach (string mime_type in pixbuf_format.get_mime_types()) { + if (mime_type == transfer.mime_type) + return getImageWidget(transfer); + } + } } + + return getDefaultWidget(transfer); } private Widget getImageWidget(FileTransfer file_transfer) { @@ -123,6 +129,8 @@ public class FileItemWidgetGenerator : WidgetGenerator, Object { return null; } + pixbuf = pixbuf.apply_embedded_orientation(); + int max_scaled_height = MAX_HEIGHT * image.scale_factor; if (pixbuf.height > max_scaled_height) { pixbuf = pixbuf.scale_simple((int) ((double) max_scaled_height / pixbuf.height * pixbuf.width), max_scaled_height, Gdk.InterpType.BILINEAR); -- cgit v1.2.3-70-g09d2