I'm running GPL Ghostscript 9.27 version.
I've compressed some PDF files (in Linux) through gs command with success, I thinked.
But after checking some particular PDFs, I've seen some modifications of the color in some pages, at least in two PDFs; in fact for example some files result to have some pages with words of entire paragraphs turned in red (besides the majority of pages left like the original, that has writings in black characters). I didn't know if the affected text was vectors, or raster (from a scan) with vector overlay.
Moreover another PDF that has some images in black and white (gray scale), now with the compression has the text (maybe as vectors) left of the same color (black), but has all the images turned in red and black. So here the problem seems different, I suppose, because affects just all the raster images. Maybe in the file where there is the raster problem there isn't the vector/text one.
Down here in the top, a part of the file with images affected, after (left) and before (right) compression; in the bottom left we have another file after compression with text (as vector) in red and in bottom right another page with text (as vector) in normal black color like the original.
.
The command I used left the version of PDF output like the original (that is specified in -dCompatibilityLevel). It is like this:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=original_version -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dSAFER -dBATCH -sOutputFile=file_out file_in
The program doesn't show me there is any error.
I tried removing the -dQUIET or the -dSAFER option, but nothing changed. To be precise the -dSAFER option should have prevented that gs change the PDF integrity.
So, how to avoid this unexpected changes with Ghostscript? What is the cause of this problem?
I've found trying the command pdfimages -list <pdf_file> with the PDF that has the images problem, that all of them have image color space of type "Separation" (column color = sep). But the same command used with other various PDFs which have just text problem (or with no problems), have image color space different (like rgb, cmyk, gray, etc.). I don't know a lot, but I suspect this difference has consequences related to those gs problems.
Thanks to Yorik for asking some explanations and clarifications.