The easiest solution is using GhostScript:
|
gs -sDEVICE=ppmraw -q -r300 -dNOPAUSE -sOutputFile=output.ppm sample.ps
|
Best you use netpbm (aka pbmplus), a toolset to handle pnm (ppm, pgm and pbm).
Use ftpsearch to locate a copy of it,
or FreeBSD there is a port in /usr/ports/graphics/netpbm/.
You can also use PicArt to handle pnm-files.
GhostScript-3.33 and later provide many DEVICES. I usually use gs within
perl to render PostScript, choose a high -r of 200 or 300 to have a good quality, too high
resolution as 600 or higher create huge ppm files. PPM format is
recommended as it's lossless true 24 bit color (RGB) and pretty simple format,
otherwise PNG or TIFF are 24 bit lossless but compressed. Call
GhostScript can be used to render Type 1 & Type 3 Fonts, but I would recommend
nowadays to use the T1LIB.
You require to write your own routines to write the picture though.
A simple Text to GIF rendering using perl:
|
# assuming $font, $points, $dpi and $s are defined
|
|
|
|
$s =~ s/\(/\\(/g;
|
|
$s =~ s/\)/\\)/g;
|
|
open(F,">my.ps");
|
|
print F "/$font findfont $points scalefont setfont\n";
|
|
print F "($s) show showpage quit\n";
|
|
close(F);
|
|
`gs -sDEVICE=ppmraw -q -r$dpi -dNOPAUSE -sOutputFile=- my.ps |\
|
|
pnmcrop | ppmquant 128 | ppmtogif > output.gif`;
|
A cheap anti-aliasing you get by using pnmscale it with -xscale .5 and -yscale .5.
