From c48e17dabf5fa53028e3f77ad3f2b75ecbf8ee0d Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Thu, 8 Aug 2019 23:33:08 +0200 Subject: [PATCH] #474: Fix java.awt.color.CMMException: Can not access specified profile (cherry picked from commit 64178bd636c61a0f85f566b548fdca13fe66252b) --- .../com/twelvemonkeys/imageio/color/ColorSpaces.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java index b9deebd8..773ec5a6 100644 --- a/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java +++ b/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java @@ -218,10 +218,14 @@ public final class ColorSpaces { } } - private static void validateColorSpace(ICC_ColorSpace cs) { - // Validate the color space, to avoid caching bad color spaces + private static void validateColorSpace(final ICC_ColorSpace cs) { + // Validate the color space, to avoid caching bad profiles/color spaces // Will throw IllegalArgumentException or CMMException if the profile is bad - cs.fromRGB(new float[] {1f, 0f, 0f}); + cs.fromRGB(new float[] {0.999f, 0.5f, 0.001f}); + + // This breaks *some times* after validation of bad profiles, + // we'll let it blow up early in this case + cs.getProfile().getData(); } /**