I am trying to convert a pdf containing grayscale pictures and black text into shades of a single color in cmyk color space (for printing). I was thus very happy to learn, from a side remark in one of Heiko Oberdiek's answers about the key decodearray of \includegraphics, which lets us specify a linear transformation on each channel of the given color space. This key places the appropriate /Decode array in the pdf file, and colors are converted when displaying or printing the pdf file.
The approach works fine for grayscale or rgb images, but fails for cmyk images, and here is why. There are two kinds of cmyk color spaces (or of cmyk jpg images?): one for which white is all zeros and one for which it is all ones. To invert colors, pdfTeX uses a /Decode array which maps the interval [0,1] to [1,0] in each channel. This second /Decode array overrides ours. See a recent answer of mine for more details.
The question is to know how I can remove the second /Decode array, or otherwise include a cmyk image with altered colors. My current solution is to post-process the pdf, replacing the second /Decode array by spaces.
Some code: first build a cmyk image
convert `kpsewhich example-image.jpg` -colorspace cmyk /tmp/example-image-cmyk.jpg
then include it
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[decodearray={1 1 0 0 1 0 0 1}]{example-image-cmyk.jpg}
\end{document}
and run pdflatex on this file. Afterwards, look at the pdf file and find the /Decode key twice in the same dictionary, and replace the second one by /Xxxxxx (or whatever key, with the same length). The pdf now has new colors.
EDIT: From an email discussion of pdfTeX developpers 6 years ago, it seems that providing the colorspace keyword to the primitive underlying \includegraphics may help.

decodearrayundocumented feature ofgraphicxhas been excised from the package, so that the technique can no longer be used even on b/w or rgb images. – Steven B. Segletes Dec 20 '17 at 13:50