You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Bob Swanson <rd...@swansongrp.com> on 2010/06/28 21:01:54 UTC

PDJpeg accepts gray-scale, but treats as RGB

When I tried to create PDJpeg objects
and display them in a created PDF
file, I found out that the PDJpeg
object accepts grayscale JPG's and
treats them as color "RGB" images
by default, without error or comment.

Due to this mismatch, the images are
damaged, and will not appear when the
PDF file is displayed in a reader.

Once I determined the mismatch to be the
problem, I had to alter my code to pre-read
the JPG files and, if they were gray-scale,
set the ColorSpace of the PDJpeg object.
I had to add code to read the JPG files
with the ImageIO static "read" method,
and check the depth of the image.

Is this the way the PDJpeg object is
supposed to work?