Ghostscript command convert pdf into large JPGE File - pdf

I have a ghostscript command that converts a pdf into several JPG images (one for every page). The command arguments are as follows:
-q -dUseCropBox -dFirstPage=1 -dLastPage=1 -dBATCH -dDOINTERPOLATE -dNOPAUSE -dSAFER -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dPrinted=false -r250 -sDEVICE=jpeg -dJPEGQ=100 -sOutputFile=output.jpg input.pdf -c quit
The pdf size is 1.5mb but in the JPGE images it becomes huge (~15MB) with dimension 8829 *15551
if I change the resolution in the ghostscript command to -r150 the page size is correct but the image quality is very rastorized.
Is there another way to decrease the image size of the image without affecting the image quality?
Thanks

Related

ghostscript pdf to postscript conversion taking long time

I am trying to convert 1000 pages PDF document to postscript file using the below command.
gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile=out.ps -f input.pdf
It takes 5 mins to convert, but in real-time, I will have more number of pages than this. I have tried with 30k pages pdf to convert ps using the same command. It takes 45mins.
After search in stack overflow, I have tried the below options of reducing resolution, set buffer memory, threading options, and all. Nothing worked. PF command below.
gswin32c.exe -q -r300 -dSAFER -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile=out.ps -dNumRenderingThreads=8 -dBufferSpace=2000000000 -f input.pdf
dCompressEntireFile option also not helps. Please, anyone, suggest improving the performance of ps conversion with Ghostscript.

Ghostscript: How to convert EPS to PDF with the same page size

I want to convert a EPS figure to a PDF figure with the same width and height.
The following command:
gswin32 -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH \
-sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 \
-dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile="test.pdf" \
-f "test.eps"
only produces a PDF file with the page size of a letter.
Any help would be much appreciated.
Here is the test EPS file: https://dl.dropboxusercontent.com/u/45318932/test.eps
EPS files cannot contain a media size request. In the absence of any media size request Ghostscript uses the default.
However.....
From the documentation:
http://www.ghostscript.com/doc/9.15/Use.htm#EPS_parameters
-dEPSCrop :
Crop an EPS file to the bounding box. This is useful when converting an EPS file to a bitmap.
To make KenS' answer more explicit, using the test.eps sample file you linked to... the following command will suffice to do what you want:
gswin32 \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/printer \
-dEPSCrop \
-o test.pdf \
test.eps
The -o test.pdf is (for not too ancient versions of Ghostscript!) shorthand for -dNOPAUSE -dBATCH -sOutputFile=test.pdf.
Your test.eps uses a font named /SHZENL+Tahoma_00. Ghostscript will automatically embed this font, and it will be a subset by default (the prefix SHZENL may change in the PDF, though).
Here is a screenshot from the page the command from your question created. That page is 612 x 792 pts (letter size):
Here is the screenshot from the page the command given in my answer created. Its page size is 360 x 216 pts:

How to set the physical size of PDF pages with Ghostscript?

I want to convert a bunch of .eps images to a single PDF using Ghostscript.
But when I look at the PDF file in a PDF viewer and set view to 100% to physical size of the file is huge!
I would like to force gs to create the PDF in letter size, but everything I tried failed.
Here's the command I'm using:
gs -dBATCH -dNOPAUSE -dEPSFitPage -dEPSCrop \
-q -sDEVICE=pdfwrite -sOutputFile=out.pdf \
file1.eps file2.eps
All my attempts with -sPAPERSIZE=legal and -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h had no effect.
-dEPSFitPage and -dEPSCrop are mutually exclusive. Try getting rid of the -dEPSCrop and putting back -sPAPERSIZE=legal. If that doesn't work, it is probably because the .eps file is over-riding the media, so try adding -dFIXEDMEDIA.
BTW, this answer is cribbed from:
Fit to page size in ghostscript (with a possibly corrupt input)
The problem was -dEPSFitPage it was fitting the page size to the .eps file size... using -dPDFFitPage (and skipping the mutually exclusive -dEPSCrop) solved my problem.
gs -dBATCH -dNOPAUSE -sPAPERSIZE=letter \
-dPDFFitPage -q -sDEVICE=pdfwrite \
-sOutputFile=out.pdf \
file1.eps file2.eps

Remove PDF margins while using PDFFitPage in GhostScript

I'm fitting a file with no margins (produced using a pdfcrop from a normal PDF file) to a given paper size using GhostScript:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dFIXEDMEDIA \
-dPDFFitPage -d -dBATCH -dQUIET -dNOPAUSE -dDEVICEWIDTHPOINTS=864 \
-dDEVICEHEIGHTPOINTS=612 -sOutputFile=$INPUT $OUTPUT
but the output has additional margins (I was cropping in order to get rid of them).
Is it possible to force GhostScript to produce output without these margins?
Without seeing your file I cannot be certain, however I suspect that all you have done is set a /CropBox in the PDF file. By default Ghostscript uses the /MediaBox which is probably unchanged.
Try setting -dUseCropBox

GhostScript removes images from some processed PDF files

I'm using this command with gs 9.01:
gs -q -dAutoRotatePages=/None -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -sOutputFile=out.pdf in.pdf in.pdfmarks
and on some processed files (out.pdf) I noticed that images are missing, although present in input file (in.pdf).
Why is this and how can I assure that images are retained after processing with gs?
1) Update to the current version, 9.04.
2) If you still experience problems, report a bug at http://bugs.ghostscript.com. You will need to attach a sample PDF file