Fit to page size in ghostscript (with possibly damaged input)

I am trying to use ghostscript to convert a .ps file to a series of .png files, largely because I don't have a portable ps viewer.

This is the command I used:

gs -dBATCH -dEPSCrop -dEPSFitPage -sDEVICE=png16m -r300 -dNOPAUSE -sOutputFile=neptune_111115_ob1-2_13pca_boloplots_%d.png neptune_111115_ob1-2_13pca_boloplots.ps 

(.ps file is a multi-page postscript).

Exits partially from the page. I would like the images to be located inside the page.

I can include example files, but they are quite large - is there any specific part of the .ps file that will be useful?

My suspicion is that the .ps file does not set the bounding box correctly, but cracking the BB values ​​has no effect. The .ps file is written by IDL (ittvis "Interactive Data Language"). I also tried this command without the -dEPS * commands without any luck.

+6
source share
1 answer

-dEPSCrop and -dEPSFitPage are mutually exclusive:

  • Highlight the EPS in the BoundingBox specified in the comments.
  • Others scale EPS from the %%BoundingBox specified in the internal comments of the PS file to match the current media.

You cannot use both at the same time.

A file cannot be an EPS file anyway, because you cannot have multiple pages in an EPS file. Thus, in fact, none of the switches will have any effect (as you discovered).

How PostScript asks for media size using setpage or setpagedevice , or simply uses what was in the currently installed media. I assume that it just uses the current media. Try setting -sPAPERSIZE=a4 and -sPAPERSIZE=letter .

If this works, the program does not request media size. If this does not work, add -dFIXEDMEDIA , which will ignore subsequent requests for resizing media.

This should allow you to specify the correct media size, if you do not know what the media size should be, then you can use the device Ghostscript -sDEVICE=bbox to find out.

Finally, Ghostscript has a rudimentary display device that you can use to view the output without first switching to PNG.

+12
source

Source: https://habr.com/ru/post/901545/


All Articles