1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19669 from timvandermeij/icc-colorspace-404

Don't get ICC color space files if required API options are missing
This commit is contained in:
Tim van der Meij 2025-03-16 18:45:21 +01:00 committed by GitHub
commit e738566900
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 6 deletions

View file

@ -289,7 +289,7 @@ class ColorSpaceUtils {
}
static get cmyk() {
if (IccColorSpace.isUsable) {
if (CmykICCBasedCS.isUsable) {
try {
return shadow(this, "cmyk", new CmykICCBasedCS());
} catch {

View file

@ -130,11 +130,15 @@ class IccColorSpace extends ColorSpace {
static get isUsable() {
let isUsable = false;
if (this.#useWasm) {
try {
this._module = QCMS._module = this.#load();
isUsable = !!this._module;
} catch (e) {
warn(`ICCBased color space: "${e}".`);
if (this.#wasmUrl) {
try {
this._module = QCMS._module = this.#load();
isUsable = !!this._module;
} catch (e) {
warn(`ICCBased color space: "${e}".`);
}
} else {
warn("No ICC color space support due to missing `wasmUrl` API option");
}
}
@ -169,6 +173,19 @@ class CmykICCBasedCS extends IccColorSpace {
static setOptions({ iccUrl }) {
this.#iccUrl = iccUrl;
}
static get isUsable() {
let isUsable = false;
if (IccColorSpace.isUsable) {
if (this.#iccUrl) {
isUsable = true;
} else {
warn("No CMYK ICC profile support due to missing `iccUrl` API option");
}
}
return shadow(this, "isUsable", isUsable);
}
}
export { CmykICCBasedCS, IccColorSpace };