summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-07-08 17:06:28 -0400
committerraveit65 <[email protected]>2019-09-12 15:59:22 +0200
commit3bdabe92391f3dbc72b3cdafdd6b7caddb7311e6 (patch)
tree26a71206ef04120407512f8d2686871d9619600d
parent1cfb72d9017f302eddcc3f8f85cfd6bcb3d17d51 (diff)
downloadeom-3bdabe92391f3dbc72b3cdafdd6b7caddb7311e6.tar.bz2
eom-3bdabe92391f3dbc72b3cdafdd6b7caddb7311e6.tar.xz
EomMetadataReaderPNG: Only build profile from cHRM if gAMA is present
It's more likely that such an image had a (stripped) sRGB profile or chunk. And thus rather than trying to build a profile from only half the necessary information, eom should not. https://bugzilla.gnome.org/show_bug.cgi?id=725359 upstream commit: https://gitlab.gnome.org/GNOME/eog/commit/78c0153e
-rw-r--r--src/eom-metadata-reader-png.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/eom-metadata-reader-png.c b/src/eom-metadata-reader-png.c
index 8ad2405..ebf2ddf 100644
--- a/src/eom-metadata-reader-png.c
+++ b/src/eom-metadata-reader-png.c
@@ -574,11 +574,11 @@ eom_metadata_reader_png_get_icc_profile (EomMetadataReaderPng *emr)
profile = cmsCreate_sRGBProfile ();
}
- if (!profile && priv->cHRM_chunk) {
+ if (!profile && priv->cHRM_chunk && priv->gAMA_chunk) {
cmsCIExyY whitepoint;
cmsCIExyYTRIPLE primaries;
cmsToneCurve *gamma[3];
- double gammaValue = 2.2; // 2.2 should be a sane default gamma
+ double gammaValue;
/* This uglyness extracts the chromacity and whitepoint values
* from a PNG's cHRM chunk. These can be accurate up to the
@@ -597,14 +597,9 @@ eom_metadata_reader_png_get_icc_profile (EomMetadataReaderPng *emr)
primaries.Blue.x = EXTRACT_DOUBLE_UINT_BLOCK_OFFSET (priv->cHRM_chunk, 6, 100000);
primaries.Blue.y = EXTRACT_DOUBLE_UINT_BLOCK_OFFSET (priv->cHRM_chunk, 7, 100000);
- primaries.Red.Y = primaries.Green.Y = primaries.Blue.Y = 1.0;
-
- /* If the gAMA_chunk is present use its value which is saved
- * the same way as the whitepoint. Use 2.2 as default value if
- * the chunk is not present. */
- if (priv->gAMA_chunk)
- gammaValue = (double) 1.0/EXTRACT_DOUBLE_UINT_BLOCK_OFFSET (priv->gAMA_chunk, 0, 100000);
+ whitepoint.Y = primaries.Red.Y = primaries.Green.Y = primaries.Blue.Y = 1.0;
+ gammaValue = (double) 1.0/EXTRACT_DOUBLE_UINT_BLOCK_OFFSET (priv->gAMA_chunk, 0, 100000);
gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma (NULL, gammaValue);
profile = cmsCreateRGBProfile (&whitepoint, &primaries, gamma);