Skip to content

Commit e738566

Browse files
Merge pull request #19669 from timvandermeij/icc-colorspace-404
Don't get ICC color space files if required API options are missing
2 parents 4c5ad92 + f44cba8 commit e738566

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/core/colorspace_utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class ColorSpaceUtils {
289289
}
290290

291291
static get cmyk() {
292-
if (IccColorSpace.isUsable) {
292+
if (CmykICCBasedCS.isUsable) {
293293
try {
294294
return shadow(this, "cmyk", new CmykICCBasedCS());
295295
} catch {

src/core/icc_colorspace.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ class IccColorSpace extends ColorSpace {
130130
static get isUsable() {
131131
let isUsable = false;
132132
if (this.#useWasm) {
133-
try {
134-
this._module = QCMS._module = this.#load();
135-
isUsable = !!this._module;
136-
} catch (e) {
137-
warn(`ICCBased color space: "${e}".`);
133+
if (this.#wasmUrl) {
134+
try {
135+
this._module = QCMS._module = this.#load();
136+
isUsable = !!this._module;
137+
} catch (e) {
138+
warn(`ICCBased color space: "${e}".`);
139+
}
140+
} else {
141+
warn("No ICC color space support due to missing `wasmUrl` API option");
138142
}
139143
}
140144

@@ -169,6 +173,19 @@ class CmykICCBasedCS extends IccColorSpace {
169173
static setOptions({ iccUrl }) {
170174
this.#iccUrl = iccUrl;
171175
}
176+
177+
static get isUsable() {
178+
let isUsable = false;
179+
if (IccColorSpace.isUsable) {
180+
if (this.#iccUrl) {
181+
isUsable = true;
182+
} else {
183+
warn("No CMYK ICC profile support due to missing `iccUrl` API option");
184+
}
185+
}
186+
187+
return shadow(this, "isUsable", isUsable);
188+
}
172189
}
173190

174191
export { CmykICCBasedCS, IccColorSpace };

0 commit comments

Comments
 (0)