Compare commits

...

6 Commits

Author SHA1 Message Date
Jonas Jenwald
6243afa85e
Merge pull request #19675 from Snuffleupagus/IccColorSpace-fetchSync
Introduce a `fetchSync` helper function for the `IccColorSpace` classes
2025-03-17 20:22:00 +01:00
Jonas Jenwald
2f1497c9c4
Merge pull request #19677 from Snuffleupagus/issue-19676
For JPEG images with CMYK-data, ensure that the alpha-component is set correctly when WebAssembly is disabled (issue 19676)
2025-03-17 20:17:00 +01:00
Jonas Jenwald
afb14bdc0b For JPEG images with CMYK-data, ensure that the alpha-component is set correctly when WebAssembly is disabled (issue 19676) 2025-03-17 16:15:32 +01:00
Jonas Jenwald
1fb6edc713 Introduce a fetchSync helper function for the IccColorSpace classes
This reduces code duplication a tiny bit, which shouldn't hurt.
2025-03-17 14:58:53 +01:00
Jonas Jenwald
e37236e9af
Merge pull request #19673 from Snuffleupagus/rm-ftl-comment
Remove documentation for unused l10n variable (PR 18492 follow-up)
2025-03-17 14:28:12 +01:00
Jonas Jenwald
e5e0856f99 Remove documentation for unused l10n variable (PR 18492 follow-up)
Looking at PR 18492 it doesn't seem that the `$percent` variable, for the `pdfjs-editor-new-alt-text-ai-model-downloading-progress` l10n-string, was ever used.
2025-03-17 12:20:30 +01:00
4 changed files with 35 additions and 20 deletions

View File

@ -480,7 +480,6 @@ pdfjs-editor-new-alt-text-error-close-button = Close
# Variables:
# $totalSize (Number) - the total size (in MB) of the AI model.
# $downloadedSize (Number) - the downloaded size (in MB) of the AI model.
# $percent (Number) - the percentage of the downloaded size.
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
.aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)

View File

@ -28,6 +28,17 @@ import { shadow, warn } from "../shared/util.js";
import { ColorSpace } from "./colorspace.js";
import { QCMS } from "../../external/qcms/qcms_utils.js";
function fetchSync(url) {
// Parsing and using color spaces is still synchronous,
// so we must load the wasm module synchronously.
// TODO: Make the color space stuff asynchronous and use fetch.
const xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.responseType = "arraybuffer";
xhr.send(null);
return xhr.response;
}
class IccColorSpace extends ColorSpace {
#transformer;
@ -132,7 +143,9 @@ class IccColorSpace extends ColorSpace {
if (this.#useWasm) {
if (this.#wasmUrl) {
try {
this._module = QCMS._module = this.#load();
this._module = QCMS._module = initSync({
module: fetchSync(`${this.#wasmUrl}qcms_bg.wasm`),
});
isUsable = !!this._module;
} catch (e) {
warn(`ICCBased color space: "${e}".`);
@ -144,30 +157,16 @@ class IccColorSpace extends ColorSpace {
return shadow(this, "isUsable", isUsable);
}
static #load() {
// Parsing and using color spaces is still synchronous,
// so we must load the wasm module synchronously.
// TODO: Make the color space stuff asynchronous and use fetch.
const filename = "qcms_bg.wasm";
const xhr = new XMLHttpRequest();
xhr.open("GET", `${this.#wasmUrl}${filename}`, false);
xhr.responseType = "arraybuffer";
xhr.send(null);
return initSync({ module: xhr.response });
}
}
class CmykICCBasedCS extends IccColorSpace {
static #iccUrl;
constructor() {
const filename = "CGATS001Compat-v2-micro.icc";
const xhr = new XMLHttpRequest();
xhr.open("GET", `${CmykICCBasedCS.#iccUrl}${filename}`, false);
xhr.responseType = "arraybuffer";
xhr.send(null);
super(new Uint8Array(xhr.response), "DeviceCMYK", 4);
const iccProfile = new Uint8Array(
fetchSync(`${CmykICCBasedCS.#iccUrl}CGATS001Compat-v2-micro.icc`)
);
super(iccProfile, "DeviceCMYK", 4);
}
static setOptions({ iccUrl }) {

View File

@ -15,6 +15,7 @@
import { assert, BaseException, warn } from "../shared/util.js";
import { ColorSpaceUtils } from "./colorspace_utils.js";
import { DeviceCmykCS } from "./colorspace.js";
import { grayToRGBA } from "../shared/image_utils.js";
import { readUint16 } from "./core_utils.js";
@ -1349,6 +1350,13 @@ class JpegImage {
_convertCmykToRgba(data) {
ColorSpaceUtils.cmyk.getRgbBuffer(data, 0, data.length / 4, data, 0, 8, 1);
if (ColorSpaceUtils.cmyk instanceof DeviceCmykCS) {
// The alpha-component isn't updated by `DeviceCmykCS`, doing it manually.
for (let i = 3, ii = data.length; i < ii; i += 4) {
data[i] = 255;
}
}
return data;
}

View File

@ -2960,6 +2960,15 @@
"rounds": 1,
"type": "eq"
},
{
"id": "cmykjpeg_nowasm",
"file": "pdfs/cmykjpeg.pdf",
"md5": "85d162b48ce98503a382d96f574f70a2",
"link": false,
"rounds": 1,
"type": "eq",
"useWasm": false
},
{
"id": "issue4402_reduced",
"file": "pdfs/issue4402_reduced.pdf",