I have (a couple) of PNG images with a background color of, for example, RGB(80,64,83):
that when placed on a page of the same background color with graphicx
-- they show a distinct tonality against the background -- which is of the same color, when run under XeLaTeX. There are no problems under pdfLaTeX or LuaLaTeX.
\documentclass{report}
\usepackage{xcolor}
\definecolor{bgcolor}{RGB}{80,64,83}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\pagecolor{bgcolor}
\includegraphics[width=0.5\textwidth]{A.png}
\quad
\includegraphics[width=0.5\textwidth]{B.png}
\medskip
\includegraphics[width=0.5\textwidth]{A-gimp.png}
\quad
\includegraphics[width=0.5\textwidth]{B-gimp.png}
\end{document}
Checking the colors in the included files one can see they have changed from (80,64,83) to (71,56,74) in the included images.
Just opening the images on GIMP
and exporting it as-is with the default choices of
fixes everything and the new inclusion now gets the exact color they were set to begin with, the same as the background, as shown below (second line). Also processing the images with pdflatex
or lualatex
does not show the problem.
What is that XeTeX needs from the PNG's to preserve their color when included in a page?
For experimentation here are the same images, after opening and closing with GIMP
:
Edit on Jan 10, 2021: The problem only displays when run under XeLaTeX. There are no problems under pdfLaTeX or LuaLaTeX.
Edit on Jan 11, 20201: Ulrike Fischera (at TeXhax) have determined the problem lies with dvipdfmx
, the backend of xetex
processing. She and and David Purton (below) looking at the PDF found that it uses the wrong color space (CalRGB) for the first two images and DeviceRGB for the last two.
\pagecolor{bgcolor}
match with the four backgroungs of your images, and using\definecolor{bgcolor}{RGB}{71,56,74}
match only with nested darker images (2nd and 3th image). It is a problem of the original files that is not in what you posted. The difference of colors seems that of a CMYK to RGB conversion (afaik, PNG cannot manage information in CMYK format).GIMP
, even though all RGB values are the same. And finally, there are no CMYK steps in this process, all images have been generated as PNG's using RGB and the LaTeX file is fully in RGB as well.