I'm running GPL Ghostscript 9.27 ghostscript version.
I've compressed some PDF files (in Linux) through gs command probably with success (based on what I've seen).
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'm talking about text data as vector symbols.
Moreover another PDF that has some images in black and white (gray scale), now with the compression has the text (as vectors) left of the same color (black), but has all the images turned in red and black. So here the problem is different, I suppose, because affects just all the raster images. So in the file where there is the raster problem there isn't the vector 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 give me any errors.
I tried removing the -dQUIET or the -dSAFER option, but nothing changed. Among other things I thought that -dSAFER option should have prevented that gs change the PDF integrity.
The command seemed to work fine for me, until now.
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 problem that affects raster images, that all images have image color space of type "Separation" (column color = sep). But the same command with other various PDF with just text problem (or with no problems), have image color space different (like rgb, cmyk, gray, etc.). I don't know a lot about if this difference has consequences related to raster gs problem.
Thanks to Yorik for asking some explanations and clarifications.