[gnome-photos] base-item: Adjust the extension when exporting
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-item: Adjust the extension when exporting
- Date: Thu, 6 Oct 2016 09:33:39 +0000 (UTC)
commit ff3c7d076706907fc55952121454e4e712e56e79
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Oct 5 11:17:48 2016 +0200
base-item: Adjust the extension when exporting
We export PNGs as PNGs, and anything else is converted to JPEG.
Therefore, we should ensure that the extension matches the exported
content type.
https://bugzilla.gnome.org/show_bug.cgi?id=772443
src/photos-base-item.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index ca804ee..72225c5 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1746,6 +1746,9 @@ photos_base_item_save_buffer_zoom (GObject *source_object, GAsyncResult *res, gp
GeglBuffer *buffer = GEGL_BUFFER (source_object);
GeglBuffer *buffer_zoomed = NULL;
PhotosBaseItemSaveData *data;
+ const gchar *extension;
+ gchar *basename = NULL;
+ gchar *filename = NULL;
self = PHOTOS_BASE_ITEM (g_task_get_source_object (task));
priv = photos_base_item_get_instance_private (self);
@@ -1764,7 +1767,11 @@ photos_base_item_save_buffer_zoom (GObject *source_object, GAsyncResult *res, gp
g_assert_null (data->buffer);
data->buffer = g_object_ref (buffer_zoomed);
- file = g_file_get_child (data->dir, priv->filename);
+ basename = photos_utils_filename_strip_extension (priv->filename);
+ extension = g_strcmp0 (priv->mime_type, "image/png") == 0 ? ".png" : ".jpg";
+ filename = g_strconcat (basename, extension, NULL);
+
+ file = g_file_get_child (data->dir, filename);
photos_utils_file_create_async (file,
G_FILE_CREATE_NONE,
G_PRIORITY_DEFAULT,
@@ -1773,6 +1780,8 @@ photos_base_item_save_buffer_zoom (GObject *source_object, GAsyncResult *res, gp
g_object_ref (task));
out:
+ g_free (basename);
+ g_free (filename);
g_clear_object (&buffer_zoomed);
g_clear_object (&file);
g_object_unref (task);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]