Summary: | Ghostscript doesn't convert EPS | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | Samuele Kaplun <samuele.kaplun> |
Component: | PS Interpreter | Assignee: | Ken Sharp <ken.sharp> |
Status: | RESOLVED INVALID | ||
Severity: | major | ||
Priority: | P4 | ||
Version: | 9.19 | ||
Hardware: | PC | ||
OS: | Linux | ||
Customer: | Word Size: | --- | |
Attachments: | the file I am trying to convert |
Description
Samuele Kaplun
2017-07-19 06:58:44 UTC
EPS files are meant to be included in other PostScript programs by an application, they are not intended to be used on their own. As such, EPS files are not permitted to use the 'showpage' operator which transfers the rendered image to the output file. Since your file (correctly) doesn't include a showpage, the rendered output is never written. If you append a 'showpage' to your EPS file, or in any other way execute showpage after the EPS is interpreted, then the content will be rendered. Dear Ken, thanks a lot for the prompt response. So the only way to have the output being produced is literally to append the string to the input file? Or is there some other way to concatenate it so that it can be run in one command without touching the input? Best regards, Samuele There are other ways. You could use the EPS the way EPS files are intended to be used; load it into a document and print the total document to PostScript. Or you could drop the -dBATCH and -dNOPAUSE from the command line, then at the 'GS>' interactive prompt, type showpage and then quit. Or you could create a file which only has the single word showpage in it, and then supply that as an additional file to be run after the EPS file, or you could use the -c and -f switches (after the input filename) to supply PostScript on the command line. There may be other ways as well, but there's certainly no shortage. Note that -c showpage can be appended to your arguments: gs -q -g553x475 -r72 -sDEVICE=ppmraw -o /tmp/tmpwifcPN d15-120f10.eps -c showpage Note that -r72 is equivalent to: -r72.000000x72.000000 and -o /tmp/tmpwifcPN is equivalent to: -dBATCH -dNOPAUSE -sOutputFile=/tmp/tmpwifcPN and -c "0 0 translate" does nothing. If -c is used before the input file, then -f is needed before the input file, otherwise it is optional (but still could be used) Dear Ken and Ray, thank you both for the valuable suggestions. They are surely going to help solving the bug I have in Pyhon-Pillow! Best regards, Samuele Was this feature introduced in some particular Ghostscript version? I have sent a pull-request to the Pillow project simply adding the suggested "-c showpage" command, and it seems that Pillow's tests are now failing everywhere but on one particular distribution: https://travis-ci.org/python-pillow/Pillow/builds/255403650?utm_source=github_status&utm_medium=notification (which might very well be the one I am also having on my production). (In reply to Samuele Kaplun from comment #6) > Was this feature introduced in some particular Ghostscript version? Which feature ? The -c switch ? That's been around for a long time. > I have sent a pull-request to the Pillow project simply adding the suggested > "-c showpage" command, and it seems that Pillow's tests are now failing > everywhere but on one particular distribution: > https://travis-ci.org/python-pillow/Pillow/builds/ > 255403650?utm_source=github_status&utm_medium=notification > (which might very well be the one I am also having on my production). Perhaps the test files are not EPS files, or are not single files. If you add a showpage to a PostScript program you will get an extra (blank) page produced. Beyond that, can't comment, I'd need to see the files. It only occurred to me last night, but Ghostscript is actually supposed to add an implicit 'showpage' when asked to render an EPS file. (this is non-standard, but useful, behaviour for a PostScript RIP) So why doesn't it do so in this case ? Well the answer is simple, this isn't a valid EPS file. In order to be an EPS file there are a number of rules which need to be followed, these cover which operators can be used, but also specify a number of comments which must be present. In particular the EPS file must include something like this comment: %!PS-Adobe-3.1 EPSF-3.0 which states that the file is a PostScript program (%!PS), conforms to version 3.1 of the Adobe Document Structure Convention, is an EPS file (EPSF) and conforms ot version 3.0 o the EPS specification. The 'EPS' file supplied here instead has: %!PS-Adobe-2.0 Which states that its a PostScript program, conforming to version 2.0 of the Document Structure Convention. Note that comments are not required in any PostScript program and may be ignored by a conforming interpreter. They are, however, required for EPS files. Since this declares itself as a PostScript program, and not an EPS file, Ghostscript treats it as such and does not add an implicit showpage. If I modify the original file to use the EPS header instead, then Ghostscript does add the showpage. So, in short, Ghostscript is doing everything its supposed to. |