PSTOIMG(1)
π pstoimg β that's PSTOIMG(1), bestie π
User Contributed Perl Documentation, section 1. Yes, it's a perl script masquerading as a man page, and yes, it's about to convert your PostScript into cute little bitmaps. Slay.
β¨ NAME β¨
pstoimg β Convert a PostScript file to a bitmap image using Ghostscript and the Netpbm utilities π¦
π SYNOPSIS π
pstoimg -help | -version
pstoimg [ -antialias ] [ -aaliastext ] [ -center num ] [ -color num ]
[ -crop code ] [ -debug ] [ -density num] [ -depth num ] [ -discard ]
[ -flip code ] [ -geometry XxY ] [ -interlaced ] [ -margins X,Y ]
[ -multipage ] [ -out file ] [ -quiet ] [ -rightjustify num ]
[ -scale num ] [ -tmp path ] [ -topjustify [x]num ] [ -transparent ]
[ -type type ] [ -shoreup num[d] ] [ -white ] file [ file2 ... ]
πΈ OPTIONS πΈ
okay so, the command line options may be abbreviated to the shortest unique prefix. iykyk β type just enough letters and pstoimg will figure out the vibe you're going for. π
-helpβ shows you this help page and then dips. Bye! π-versionβ prints the release and version ofpstoimgand exits. Very "who am I, what am I" of it.-antialiasβ turns on Ghostscript's anti-aliasing so your images render "softer". This applies to lines and edges of polygonal and oval or circular shapes. Only valid if Ghostscript 4.03 or higher is installed, so check before you commit, bestie.-aaliastextβ also Ghostscript anti-aliasing, but this time for "smoother" font characters, so no jagged edges on your letters. Basically-antialiasbut for graphic components. Only valid if Ghostscript 4.03 or higher is installed β same deal.-center numβ adds the right amount of whitespace to the left of the image so it looks centered inside a total width of num pixels. Visual balance, we love to see it. β¨-crop codeβ crops the bitmap from the directions you pick. code can be a string of several cropping instructions, and they get executed strictly in the given order β so order matters, no cap. Possible values:hβ horizontal, i.e. crop top and bottomvβ verticaltblrβ top, bottom, left, rightaβ all directions
And a special case: s, which "shaves" the image at the bottom, but only if a single line of whitespace exists. Situational icon behavior.
-debugβ turns on debugging output. This can get rather verbose, fr fr. Any intermediate files that get generated are not removed, so you can go poke at them and figure out what's going on. π΅οΈ-density numβ the density (resolution) in DPI to render the bitmap at. The default is72.-depth numor-color numβ sets the color depth of the bitmap. Legal values are1(black & white),8(256 colors) and24(true color). Pick your palette, main character. π¨-discardβ deletes the input PostScript file if the conversion was successful. Setting the environment variableDISCARDto a true value (as perl sees it) has the same effect. That's your input file, gone, poof. π-flip codeβ flips all generated output bitmaps. The recognized codes are:lrβ flip left-righttbβ flip top-bottomxyβ flip bottom/left-top/rightr90andccwβ rotate by 90 degrees counterclockwiser270andcwβ rotate 90 degrees clockwiser180β rotate 180 degrees
-geometry XxYβ renders only this "window" of the PostScript file. If you give it, this option can dramatically reduce memory requirements and speed up conversion. And for EPS files (Encapsulated PostScript), the geometry is detected automatically. π«Ά-interlacedβ generates an interlaced bitmap. Interlaced images build up from coarse to fine as they load, which is honestly a little iconic. This option may not work on every installation and/or bitmap type, depending on what the external programs can do.-margins X,Yβ the offset of the rectangle in the postscript file that's going to be rendered, from top/left. You can use it together with-geometryto shrink the intermediate bitmap file Ghostscript generates even further. Teamwork!-multipageβ processes a multi-page PostScript file, i.e. makes an individual bitmap for every page. The resulting files are numbered: the decimal number (starting with1) gets appended to the basename of the PostScript input file β or the basename of the filename you gave with-outβ while keeping the extension. ποΈ-out fileβ the file to write the bitmap to. If you supply multiple PostScript files on the command line, this option is ignored. The bitmap type extension is appended automatically if file doesn't contain a dot. In connection with-multipage, file gets extended by the page number, like this:
-outfile foo.gif --------> foo1.gif, foo2.gif, ...
-quietβ do not print anything except error messages. Silence. π€«-rightjustify numβ adds the appropriate amount of whitespace to the left of the image so it appears aligned to the right inside a total width of num pixels. Right-aligned and thriving.-scale factorβ scales the image by factor. Valid choices are any numbers greater than zero. Useful choices are numbers between0.1and5. Large numbers may generate very large intermediate files and will take longer to process, so be normal about it. If you omit this option, the environment variableSCALEis considered.-shoreup num[d]β makes height and width of the bitmap(s) an exact multiple of num. If num is followed by ad, then half the extra vertical space is placed underneath. This one's useful if you want "blown-up" images of high quality for print but then downscale them in HTML using<IMG WIDTH=x HEIGHT=y>. The tea is: if the actual image isn't an integer multiple of x,y then browsers tend to display distorted images. Distorted is NOT the vibe. π«-tmp pathβ use path to store temporary files. Defaults to/tmpon this installation. You can set this parameter with the environment variablesTMPorTEMPtoo.-topjustify [x]numβ adds padding whitespace to the image so it gets a defined height. If an integer value is given, it defines the total height. The whitespace is added at the bottom. If the number is preceded by anx, then this multiple of the image height is added as whitespace at the bottom. Padding queen. π-transparentβ generates transparent bitmaps, i.e. the background color (white) is transparent if viewed with certain viewers (e.g. browsers). This option may not be available due to missing capabilities of external programs.-type typeβ tells pstoimg to render the bitmap in type format. Depending on the local installation, pstoimg is capable of generating either GIF or PNG bitmaps. This site features the following types:pnggif
If omitted, the first type in this list is taken.
-whiteβ removes TeX's page color information from the PostScript file before converting, so that a white background is used. Clean, crisp, white. π€
π DESCRIPTION π
pstoimg iterates over the given input files and runs them through Ghostscript. The resulting pnm (portable anymap files) get processed with different Netpbm tools β cropping, color mapping, aligning, all of that β and finally converted into (currently) either GIF or PNG format. Then you can include those bitmaps in, say, WWW pages. β¨
The PostScript file is converted as is. If a valid bounding box is found (EPS format), then only that area is converted. And the image is not cropped by default β you gotta ask for that.
π RETURN VALUE π
0β if everything went all right πxβ (x != 0) something went wrong. See the message output. π
π¦ EXAMPLES π¦
pstoimg foo.psβ Convert the first page offoo.psto the default bitmap type.pstoimg -type png -crop a -trans -interlace foo.psβ Same as above, but force png output and crop all the whitespace around the image and make the color white transparent and generate an interlaced bitmap.pstoimg -multi -out bar -type gif -crop a foo.psβ Considerfoo.psa multiple page PostScript file and create output filesbar1.gif,bar2.gif, etc.
π§ ENVIRONMENT π§
DENSITY,DEPTH,DEBUG,DISCARDβ See-density,-depth,-debug,-discard, respectively.GS_LIBβ this variable is set to the path(s) where Ghostscript libraries have been found on this system during configuration, but only if the built-in paths are not correct. This fixes the problem of relocation that is quite common on Win32 installations. You can override this behavior by settingGS_LIBmanually before startingpstoimg.LATEX2HTMLDIRβ the directory where the LaTeX2HTML library and perl modules are found. Defaults to/usr/share/latex2htmlon this installation.OUTFILEβ setting this has the same effect as specifying-out. Please do not rely on this feature any more, it will disappear from the next releases! π¨PAPERSIZEβ the papersize to use by Ghostscript to render the image.pstoimgtries hard to optimize for rendering on the smallest possible bitmap size. Still, this option is there to enable tuning by hand, although it is deprecated. If pstoimg finds a better setting, this parameter is ignored.SCALEβ See the discussion of-scale.TMPandTEMPβ unless overridden by-tmp, these variables denote a directory where to store temporary files.TMPis considered first, thenTEMP.
π SEE ALSO π
gs, pnmcrop, pnmquant, pbmmake, pnmcat, pnmfile, pnmflip, ppmtogif, pnmtopng, giftool, giftrans.
π NOTES π
Several people have suggested using ImageMagick's convert instead of pstoimg. A few comments on this, because bestie, I have thoughts:
convert uses (of course) Ghostscript for conversion of PostScript to bitmap, so you still need gs. And for the special requirements of LaTeX2HTML, convert's features are not sufficient. The ImageMagick toolset has everything in place, but it has some overhead that can prove killing when processing some 100 images. pstoimg only does what it really has to, so it should be quite efficient. Don't get me wrong β I like ImageMagick, but not in the context of LaTeX2HTML.
π CAVEATS π
This utility is automatically configured and built to work on the local setup. If this setup changes (e.g. some of the external commands are moved), the script has to be reconfigured.
And despite the portability of perl, a pstoimg configured on UNIX will probably not work on Win32 and vice versa. Sad but true.
β BUGS β
This is a major enhancement release, so there may be a few bugs. π And as the user interface changed a bit, some of your tools that were using pstoimg may not work any more. Heads up.
Please report bugs to latex2html@tug.org, stating the (debug) output of pstoimg, your perl version and the versions of the external tools. Best is to include the cfgcache.pm file from the configuration procedure. π«Ά
π AUTHOR π
Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
β¨ HISTORY β¨
okay so this little script has been through it β like, a full glow-up era arc. π¦ it all started as a modification of Doug Crabill <dgc@cs.purdue.edu>'s ps2epsi script, which is giving "humble beginnings" in the best way.
then Nikos Drakos <nikos@cbl.leeds.ac.uk> came through and did the first perl version. iconic behavior, truly. π
after that it got gradually improved by a whole squad of LaTeX2HTML developers β Ross Moore <ross@mpce.mq.edu.au>, Jens Lippmann <lippmann@rbg.informatik.tu-darmstadt.de>, and others. and to everyone who got left out of the shoutout: sorry for not mentioning everyone and thanks for your contributions π«Ά (the original really said that, and honestly? we love the honesty.)
and that's a wrap bestie π this page lives in perl v5.8.4, dated 2005-03-20, and it's filed under PSTOIMG(1) β the manpage that understood the assignment, no cap. πβ¨
π¦ where this page comes from
- centos-stream 10: latex2html 2023.2-7.el10 Β· GPL-2.0-or-later
- centos-stream 9: latex2html 2020.2-5.el9 Β· GPLv2+
- fedora 43: latex2html 2023.2-8.fc43 Β· GPL-2.0-or-later
- fedora 44: latex2html 2023.2-9.fc44 Β· GPL-2.0-or-later
- fedora 44: latex2html 2026-1.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms