Reputation: 55
I am attempting to use Ghostscript to convert a PS file first to PDF, then to BMP, along with some scaling at both conversions.
To convert my PS file to PDF, here are my arguments:
-g2838x4551 -r720 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=""FILE PATH TO DUMP PDF IN HERE"" -c save pop -f ""FILE PATH TO GRAB PS FROM HERE""
this part of my code is working fine.
To convert my new PDF file to BMP, here are my arguments:
-dSAFER -dBATCH -dNOPAUSE -sDEVICE=bmp256 -sOutputFile=""OUTPUT BMP FILE LOCATION"" " & PDF FILE LOCATION & "
In terms of just converting from PDF to BMP, this is working. However, I'd like to scale it up a bit, to 374x635 pixels. I have attempted to do this with various switches, such as
-g374X635
-dPDFFITPage
-dDEVICEWIDTH=374 -dDEVICEHEIGHT=635
-dFIXEDMEDIA
or some combination of the above. The -dDEVICEWIDTH and -dDEVICEHEIGHT switches don't seem to be working at all, and while -g374x635 is increasing the BMP to the correct size, it seems like it's just adding white space to get to the correct size, instead of scaling the entire PDF up the way I want it to.
Upvotes: 0
Views: 916
Reputation: 31139
It might help if you explained why you want to produce a PDF from the PostScript and BMP from the PDF, instead of producing both from the same input....
DEVICEHEIGHTPOINTS
and DEVICEWIDTHPOINTS
need to be used in combination with FIXEDMEDIA
if you want to then use FitPage
, as all they do is set the current media size which can then be overridden, unless you fix it.
The PDF interpreter calls setpagedevice
for every page, because PDF files can contain different media sizes for each page, so unless you set FIXEDMEDIA
it will resize each page of output for you.
-g
silently sets FIXEDMEDIA
.
The page fitting doesn't do scaling up, only down, for larger media than requested it honours the original media size and centres it on the new (larger) media.
Given that you have already created a PDF file where every page is the same fixed size, the easiest way to alter the output dimensions (in pixels) then, is simply to alter the resolution.
Now PDF files don't have a resolution as such, because they aren't a strictly bitmap format, so by setting a fixed (in pixels) size and a resolution in the original conversion to PDF what you are actually doing is creating a fixed media size. In this case you are creating a PDF file where the media size is 2838/720 by 4551/720 = 3.941666 inches by 6.3208333 inches.
When you render to a bitmap, the size of the bitmap (in pixels) is given by the media size in inches * the resolution in dpi. So working backwards, knowing that the desired size is 374x635 and the media size above, the required resolution is:
374 / 3.9416666 = 94.8837
635 / 6.3208333 = 100.4614
So using -r95x100
would produce more or less the output size you want. Note that in your original PDF creation step, you do not need -c save pop -f
Upvotes: 1