Skip to content

Commit 2f1497c

Browse files
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)
2 parents e37236e + afb14bd commit 2f1497c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/core/jpg.js

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import { assert, BaseException, warn } from "../shared/util.js";
1717
import { ColorSpaceUtils } from "./colorspace_utils.js";
18+
import { DeviceCmykCS } from "./colorspace.js";
1819
import { grayToRGBA } from "../shared/image_utils.js";
1920
import { readUint16 } from "./core_utils.js";
2021

@@ -1349,6 +1350,13 @@ class JpegImage {
13491350

13501351
_convertCmykToRgba(data) {
13511352
ColorSpaceUtils.cmyk.getRgbBuffer(data, 0, data.length / 4, data, 0, 8, 1);
1353+
1354+
if (ColorSpaceUtils.cmyk instanceof DeviceCmykCS) {
1355+
// The alpha-component isn't updated by `DeviceCmykCS`, doing it manually.
1356+
for (let i = 3, ii = data.length; i < ii; i += 4) {
1357+
data[i] = 255;
1358+
}
1359+
}
13521360
return data;
13531361
}
13541362

test/test_manifest.json

+9
Original file line numberDiff line numberDiff line change
@@ -2960,6 +2960,15 @@
29602960
"rounds": 1,
29612961
"type": "eq"
29622962
},
2963+
{
2964+
"id": "cmykjpeg_nowasm",
2965+
"file": "pdfs/cmykjpeg.pdf",
2966+
"md5": "85d162b48ce98503a382d96f574f70a2",
2967+
"link": false,
2968+
"rounds": 1,
2969+
"type": "eq",
2970+
"useWasm": false
2971+
},
29632972
{
29642973
"id": "issue4402_reduced",
29652974
"file": "pdfs/issue4402_reduced.pdf",

0 commit comments

Comments
 (0)