How to convert a PDF to PNG with ImageMagick “convert” or Ghostscript?

You can use one commandline with two commands (gs, convert) connected through a pipe, if the first command can write its output to stdout, and if the second one can read its input from stdin. Luckily, gs can write to stdout (… -o %stdout …). Luckily, convert can read from stdin (convert -background transparent – … Read more

Converting PDF to CMYK (with identify recognizing CMYK)

sdaau, the command you used for trying to convert your PDF to CMYK was not correct. Try this one instead: gs \ -o test-cmyk.pdf \ -sDEVICE=pdfwrite \ -sProcessColorModel=DeviceCMYK \ -sColorConversionStrategy=CMYK \ -sColorConversionStrategyForImages=CMYK \ test.pdf Update If color conversion does not work as desired and if you see a message like “Unable to convert color space … Read more

How do I embed fonts in an existing PDF?

This may not be the answer you are looking for (since you want to get your problems solved programmatically, not by an external tool). But you can use Ghostscript commandline to embed missing fonts in retrospect to PDFs which have not embedded them: gs \ -sFONTPATH=/path/to/fonts:/another/dir/with/more/fonts \ -o output-pdf-with-embedded-fonts.pdf \ -sDEVICE=pdfwrite \ -dPDFSETTINGS=/prepress \ input-pdf-where-some-fonts-are-not-embedded.pdf … Read more

How to downsample images within PDF file?

Here’s an example of how you can downsample all (color, gray and mono) images to 72dpi with a Ghostscript commandline: gs \ -o downsampled.pdf \ -sDEVICE=pdfwrite \ -dDownsampleColorImages=true \ -dDownsampleGrayImages=true \ -dDownsampleMonoImages=true \ -dColorImageResolution=72 \ -dGrayImageResolution=72 \ -dMonoImageResolution=72 \ -dColorImageDownsampleThreshold=1.0 \ -dGrayImageDownsampleThreshold=1.0 \ -dMonoImageDownsampleThreshold=1.0 \ input.pdf Update: The *ImageDownsampleThreshold=1.0 parameters enforce that all Images with … Read more

Using Ghostscript to convert JPEG to PDF

https://gitlab.mister-muffin.de/josch/img2pdf As mentioned by PleaseStand, GhostScript (edit: prior to v9.23) will decode the JPEG data, resulting in generation loss, as well as performance “ten to hundred” times worse than img2pdf. Edit: Ghostscript 9.23 (2018-03-21) added a “JPEG Passthrough” capability that resolves the generation-loss/performance issue. ImageMagick (i.e. convert) also decodes and re-encodes the images.

Any tips for speeding up GhostScript? [closed]

If you are on a multicore system, make it use multiple CPU cores with: -dNumRenderingThreads=<number of cpus> Let it use up to 30mb of RAM: -c “30000000 setvmthreshold” Try disabling the garbage collector: -dNOGC Fore more details, see Improving Performance section from Ghoscript docs.

File not found.