danfickle / danfickle/openhtmltopdf

javax.imageio.IIOException: Incompatible color conversion

Open
#105 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Hi,

This error occurs when I try to convert an HTML with a specific embedded base64-encoded image. Here's what I believe is the relevant part of the stack trace:

```
Caused by: javax.imageio.IIOException: Incompatible color conversion
at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkColorConversion(JPEGImageReader.java:973)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1078)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1034)
at javax.imageio.ImageReader.read(ImageReader.java:940)
at org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory.readJPEG(JPEGFactory.java:138)
at org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory.createFromByteArray(JPEGFactory.java:93)
at org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory.createFromStream(JPEGFactory.java:74)
at com.openhtmltopdf.pdfboxout.PdfBoxOutputDevice.realizeImage(PdfBoxOutputDevice.java:915)
... 55 more
```

Close to the point where the exception is thrown, I found this comment:

```
// XXX - We do not currently support any indexed color models,
// though we could, as IJG will quantize for us.
// This is a performance and memory-use issue, as
// users can read RGB and then convert to indexed in Java.

[com.sun.imageio.plugins.jpeg.JPEGImageReader:886]
```

`outColorSpaceCode == 4`, which corresponds to `JPEG.JCS_CMYK` -- one of the unsupported color models, apparently.

This is the image in question:

```

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.