You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Etienne Gautier <et...@canva.com.INVALID> on 2023/10/16 04:22:07 UTC

Incorrect colors in image from PDFs (DCTDecode)

Hello,
I am looking at a PDF where colors are rendered completely incorrectly in
PDFBox compared to other readers (Acrobat, Chrome, Apple Preview). I have
attached the file + screenshots here
<https://github.com/Etienne-Gautier/pdfbox/issues/1>

This issue doesn't seem linked to the color profile (deviceCMYK), as I have
ran this with 3 different profiles and always got the bug:

   - I*SOcoated_v2_300_bas.icc* which was used in 2.0 release
   - *CGATS001Compat-v2-micro.icc* which I contributed and was added from
   3.0 release
   - *USWebCoatedSWOP.icc* which is used by acrobat as the default
   DeviceCMYK but cannot be used by PDFBox because of a restrictive license.


I had a go at debugging *SampledImageReader.fromAny()* and *DCTFilter.* I
didn't find anything obvious but I am lacking context. Maybe someone here
can help point me in the right direction or create a fix.


Note: the images in this file are a special case in the spec: as the
*decode* array (which contains pairs of dMin, dMax) has dMin > dMax
because decode
= [1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0].

According to the spec (version 1.7, page 344 / version 2.0 page 262):

> While this formula applies to values outside the domain xmin to xmax and
> does not require that xmin < xmax, note that interpolation used for color
> conversion, such as the Decode array, does require that xmin < xmax and
> clips x values to this domain so that y = ymin for all x ≤ xmin, and y =
> ymax for all x ≥ xmax.
>

-- 
**
** <https://www.canva.com/>
Empowering the world to design
We're hiring, 
apply here <https://www.canva.com/careers/>! Check out the latest news and 
learnings from our team on the Canva Newsroom 
<https://www.canva.com/newsroom/news/>.
 <https://twitter.com/canva>
 
<https://facebook.com/canva>
 <https://au.linkedin.com/company/canva>
 
<https://twitter.com/canva>  <https://facebook.com/canva>  
<https://www.linkedin.com/company/canva> 
 <https://instagram.com/canva>