Commit 6c20609f authored by Michael Natterer's avatar Michael Natterer 😴

Bug 492048 - Detect color space in Exif 2.21/DCF 2.0 option files

Change the logic in gimp_metadata_get_colorspace() to be like in the
respective KExiv2 function, which looks pretty well done. No guarantee
of correctness, this just looks more logical than before :)
parent 153b19ac
......@@ -918,7 +918,7 @@ gimp_metadata_set_resolution (GimpMetadata *metadata,
GimpMetadataColorspace
gimp_metadata_get_colorspace (GimpMetadata *metadata)
{
glong colorspace = -1;
glong exif_cs = -1;
g_return_val_if_fail (GEXIV2_IS_METADATA (metadata),
GIMP_METADATA_COLORSPACE_UNSPECIFIED);
......@@ -927,74 +927,84 @@ gimp_metadata_get_colorspace (GimpMetadata *metadata)
if (gexiv2_metadata_has_tag (metadata, "Exif.Photo.ColorSpace"))
{
colorspace = gexiv2_metadata_get_tag_long (metadata,
"Exif.Photo.ColorSpace");
exif_cs = gexiv2_metadata_get_tag_long (metadata,
"Exif.Photo.ColorSpace");
}
else if (gexiv2_metadata_has_tag (metadata, "Xmp.exif.ColorSpace"))
{
colorspace = gexiv2_metadata_get_tag_long (metadata,
"Xmp.exif.ColorSpace");
exif_cs = gexiv2_metadata_get_tag_long (metadata,
"Xmp.exif.ColorSpace");
}
if (colorspace == 0x01)
if (exif_cs == 0x01)
{
return GIMP_METADATA_COLORSPACE_SRGB;
}
else if (colorspace == 0x02)
else if (exif_cs == 0x02)
{
return GIMP_METADATA_COLORSPACE_ADOBERGB;
}
else if (colorspace == 0xffff)
else
{
gchar *iop_index;
iop_index = gexiv2_metadata_get_tag_string (metadata,
"Exif.Iop.InteroperabilityIndex");
if (! g_strcmp0 (iop_index, "R03"))
if (exif_cs == 0xffff)
{
g_free (iop_index);
gchar *iop_index;
return GIMP_METADATA_COLORSPACE_ADOBERGB;
}
else if (! g_strcmp0 (iop_index, "R98"))
{
g_free (iop_index);
iop_index = gexiv2_metadata_get_tag_string (metadata,
"Exif.Iop.InteroperabilityIndex");
return GIMP_METADATA_COLORSPACE_SRGB;
}
if (! g_strcmp0 (iop_index, "R03"))
{
g_free (iop_index);
g_free (iop_index);
return GIMP_METADATA_COLORSPACE_ADOBERGB;
}
else if (! g_strcmp0 (iop_index, "R98"))
{
g_free (iop_index);
return GIMP_METADATA_COLORSPACE_UNCALIBRATED;
}
else if (gexiv2_metadata_has_tag (metadata, "Exif.Nikon3.ColorSpace"))
{
colorspace = gexiv2_metadata_get_tag_long (metadata,
"Exif.Nikon3.ColorSpace");
return GIMP_METADATA_COLORSPACE_SRGB;
}
if (colorspace == 0x01)
{
return GIMP_METADATA_COLORSPACE_SRGB;
}
else if (colorspace == 0x02)
{
return GIMP_METADATA_COLORSPACE_ADOBERGB;
g_free (iop_index);
}
}
else if (gexiv2_metadata_has_tag (metadata, "Exif.Canon.ColorSpace"))
{
colorspace = gexiv2_metadata_get_tag_long (metadata,
"Exif.Canon.ColorSpace");
if (colorspace == 0x01)
if (gexiv2_metadata_has_tag (metadata, "Exif.Nikon3.ColorSpace"))
{
return GIMP_METADATA_COLORSPACE_SRGB;
glong nikon_cs;
nikon_cs = gexiv2_metadata_get_tag_long (metadata,
"Exif.Nikon3.ColorSpace");
if (nikon_cs == 0x01)
{
return GIMP_METADATA_COLORSPACE_SRGB;
}
else if (nikon_cs == 0x02)
{
return GIMP_METADATA_COLORSPACE_ADOBERGB;
}
}
else if (colorspace == 0x02)
if (gexiv2_metadata_has_tag (metadata, "Exif.Canon.ColorSpace"))
{
return GIMP_METADATA_COLORSPACE_ADOBERGB;
glong canon_cs;
canon_cs = gexiv2_metadata_get_tag_long (metadata,
"Exif.Canon.ColorSpace");
if (canon_cs == 0x01)
{
return GIMP_METADATA_COLORSPACE_SRGB;
}
else if (canon_cs == 0x02)
{
return GIMP_METADATA_COLORSPACE_ADOBERGB;
}
}
if (exif_cs == 0xffff)
return GIMP_METADATA_COLORSPACE_UNCALIBRATED;
}
return GIMP_METADATA_COLORSPACE_UNSPECIFIED;
......
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