From 71bae38afbd1a417f698a5d9fb16ef95e688e4bb Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sat, 20 Jul 2024 19:14:42 +0200 Subject: [PATCH] Fallback on DeviceGray when a colorspace cannot be parsed --- src/core/colorspace.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/colorspace.js b/src/core/colorspace.js index 74b43a1c4..1b66ab6d5 100644 --- a/src/core/colorspace.js +++ b/src/core/colorspace.js @@ -396,7 +396,9 @@ class ColorSpace { } } } - throw new FormatError(`Unrecognized ColorSpace: ${cs.name}`); + // Fallback to the default gray color space. + warn(`Unrecognized ColorSpace: ${cs.name}`); + return this.singletons.gray; } } if (Array.isArray(cs)) { @@ -474,10 +476,14 @@ class ColorSpace { const range = params.getArray("Range"); return new LabCS(whitePoint, blackPoint, range); default: - throw new FormatError(`Unimplemented ColorSpace object: ${mode}`); + // Fallback to the default gray color space. + warn(`Unimplemented ColorSpace object: ${mode}`); + return this.singletons.gray; } } - throw new FormatError(`Unrecognized ColorSpace object: ${cs}`); + // Fallback to the default gray color space. + warn(`Unrecognized ColorSpace object: ${cs}`); + return this.singletons.gray; } /**