Dimensions change when Ghostscript converts PS to PNG

133 views Asked by At

I use the following minimal PostScript file:

%!PS-Adobe-2.0
%%BoundingBox: 0 0 100 100
0 0 moveto 100 100 rlineto stroke
showpage

This draws a line from (0,0) to (100,100) in a 100x100 box.

I then convert this file minimal.ps to a PNG with this command line, borrowed from GhostScript's documentation:

gs -sDEVICE=pngmono -o minimal.png minimal.ps

With GPL Ghostscript 9.53.3 (current Debian stable) and 9.27 (oldstable) the resulting PNG file has the following dimensions:

> identify minimal.png 
minimal.png PNG 612x792 612x792+0+0 8-bit Gray 2c 2994B 0.000u 0:00.000

Both width and height extend far beyond the original BoundingBox, and they are not even equal.

The PNG's dimensions are the same if the output device is pnggray, pngalpha, etc.

The dimensions are also the same if, in the PostScript code, 100 is replaced by 10 or by 10000.

How can I tell GhostScript to create a PNG file whose dimensions automatically fit the PostScript file's BoundingBox?

0

There are 0 answers