Commit 8c697da2 authored by Michael J. Chudobiak's avatar Michael J. Chudobiak
Browse files

write exiv2 metadata on file-save for jpeg and png files only, bug 594795

parent ff453158
......@@ -667,24 +667,35 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
}
extern "C"
gboolean
exiv2_supports_writes (GthFileData *file_data)
{
return (g_content_type_equals (gth_file_data_get_mime_type (file_data), "image/jpeg") ||
g_content_type_equals (gth_file_data_get_mime_type (file_data), "image/png"));
}
extern "C"
gboolean
exiv2_write_metadata (SavePixbufData *data)
{
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
g_assert (image.get() != 0);
if (exiv2_supports_writes (data->file_data)) {
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) data->buffer, data->buffer_size);
g_assert (image.get() != 0);
Exiv2::DataBuf buf = exiv2_write_metadata_private (image, data->file_data->info, data->pixbuf);
Exiv2::DataBuf buf = exiv2_write_metadata_private (image, data->file_data->info, data->pixbuf);
g_free (data->buffer);
data->buffer = g_memdup (buf.pData_, buf.size_);
data->buffer_size = buf.size_;
}
catch (Exiv2::AnyError& e) {
if (data->error != NULL)
*data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
return FALSE;
g_free (data->buffer);
data->buffer = g_memdup (buf.pData_, buf.size_);
data->buffer_size = buf.size_;
}
catch (Exiv2::AnyError& e) {
if (data->error != NULL)
*data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
return FALSE;
}
}
return TRUE;
......
......@@ -44,6 +44,7 @@ gboolean exiv2_write_metadata_to_buffer (void **buffer,
GFileInfo *info,
GdkPixbuf *pixbuf, /* optional */
GError **error);
gboolean exiv2_supports_writes (GthFileData *file_data);
G_END_DECLS
......
......@@ -87,11 +87,8 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
GError *error = NULL;
GObject *metadata;
if (! g_content_type_equals (gth_file_data_get_mime_type (file_data), "image/jpeg")
&& ! g_content_type_equals (gth_file_data_get_mime_type (file_data), "image/png"))
{
if (! exiv2_supports_writes (file_data))
return;
}
if (! g_load_file_in_buffer (file_data->file, &buffer, &size, &error))
return;
......
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