📄 pstoimg
字号:
#! /usr/bin/perl -w############################################################################### $Id: pstoimg.pin,v 1.11 1999/10/25 21:18:22 MRO Exp $## pstoimg## Accompanies LaTeX2HTML## Script to convert an arbitrary PostScript image to a cropped GIF or PNG# image suitable for incorporation into HTML documents as inlined images# to be viewed with WWW browsers.## This software is provided as is without any guarantee.################################################################################# $Log: pstoimg.pin,v $# Revision 1.11 1999/10/25 21:18:22 MRO## -- added more configure options (Jens' suggestions)# -- fixed bug in regexp range reported by Achim Haertel# -- fixed old references in documentation (related to mail list/archive)## Revision 1.10 1999/10/06 22:04:13 MRO## -- texexpand: latex2html calls texexpand with the -out option instead of# output redirection: this is safer on non-UNIX platforms# -- pstoimg: now there's no default cropping (useful for standalone# conversions). latex2html was changes appropriately# -- minor cleanups in latex2html script and documentation## Revision 1.9 1999/09/14 22:02:02 MRO## -- numerous cleanups, no new features## Revision 1.8 1999/07/19 09:51:00 RRM# -- added -aaliastext switch, for easier way to specify anti-aliased# font characters, without also anti-aliasing other graphics objects.## Revision 1.7 1999/06/24 07:28:59 MRO### -- removed L2HMODULE# -- fixed processing of -info switch# -- changed option order for dvips on win32 (thanks JCL)# -- bumped version to 99.2a8## Revision 1.6 1999/06/06 14:24:50 MRO### -- many cleanups wrt. to TeXlive# -- changed $* to /m as far as possible. $* is deprecated in perl5, all# occurrences should be removed.## Revision 1.5 1999/06/04 20:14:25 MRO### -- Reworked option parsing completely. Should behave much the same as before,# options with -no_* work just like before.# -- Changed $NOFORK to $CAN_FORK and inverted the logic.# -- Small debugging enhancement in pstoimg## Revision 1.4 1999/06/04 15:30:15 MRO### -- fixed errors introduced by cleaning up TMP*# -- made pstoimg -quiet really quiet# -- pstoimg -debug now saves intermediate result files# -- several fixes for OS/2## Revision 1.3 1999/06/01 06:55:35 MRO### - fixed small bug in L2hos/*# - added some test_mode related output to latex2html# - improved documentation# - fixed small bug in pstoimg wrt. OS2## Revision 1.2 1999/05/17 21:30:59 MRO### -- make texexpand warning-free and start making it use strict# compliant## Revision 1.1 1999/05/11 06:10:00 MRO### - merged config stuff, did first tries on Linux. Simple document# passes! More test required, have to ger rid of Warnings in texexpand## Revision 1.18 1999/05/05 19:47:03 MRO### - many cosmetic changes# - final backup before merge## Revision 1.17 1999/03/15 23:00:53 MRO### - moved L2hos modules to top level directory, so that no dir-# delimiter is necessary in the @INC-statement.# - changed strategy for "shave": Do not rely on STDERR redirection any# more (caused problems on at least Win32)## Revision 1.16 1999/02/14 23:44:34 MRO### -- first attempt to fix Win32 problems## Revision 1.15 1999/02/11 00:18:29 MRO### -- cleaned up warppers, TeXlive stuff and Makefile## Revision 1.14 1999/02/10 01:37:12 MRO### -- changed os-dependency structure again - now neat OO modules are# used: portable, extensible, neat!# -- some minor cleanups and bugfixes## Revision 1.13 1998/12/07 23:19:58 MRO### -- added POD documentation to pstoimg and did a general cleanup# -- some finetuning of config procedure and modules## Revision 1.12 1998/10/31 14:13:05 MRO# -- changed OS-dependent module loading strategy: Modules are now located in# different (OS-specific) directories nut have the same name: Easier to# maintain and cleaner code# -- Cleaned up config procedure# -- Extended makefile functionality## Revision 1.11 1998/08/09 20:45:20 MRO# -- some cleanup## Revision 1.10 1998/06/14 14:10:38 latex2html# -- Started to implement TeXlive configuration and better OS specific# handling (Batch files) (Marek)## Revision 1.9 1998/06/07 22:35:24 latex2html# -- included things I learned from the Win95 port to config procedure:# GS_LIB, Win32 module calls, directory separator stuff, ... (Marek)## Revision 1.8 1998/06/01 12:57:56 latex2html# -- Cleanup and cosmetics.## Revision 1.7 1998/05/14 22:27:37 latex2html# -- more work on config procedure (Makefile, GS_LIB)# -- tested pstoimg in 98.1 environment successfully on Linux## Revision 1.6 1998/05/06 22:31:09 latex2html# -- Enhancements to the config procedure: Added a "generic" target# in the Makefile for the TeXlive CD (not perfect yet)# -- included test for kpsewhich / Web2C# -- included latest stuff from Override.pm into os_*.pm## Revision 1.5 1998/04/28 22:18:11 latex2html# - The platform specific stuff is now kept in a separate perl module. This# does not introduce significant overhead and enhances maintainability.## Revision 1.4 1998/03/19 23:38:06 latex2html# -- made pstoimg plug-in compatible with old one (touchwood!)# -- cleaned up, added some comments# -- inserted version information output# -- incorporated patches to make OS/2 run better (thanks Uli)# -- updated Makefile: make, make test, make install should work now## Revision 1.3 1998/03/11 23:44:00 latex2html# -- cleaned up config.pl and reworked dvips checks# -- got pstoimg.pin up to par with the regular pstoimg# -- cosmetic changes# -- runs now under Win95 with Fabrice Popineau's Win32 tools (gs, TeX,...)## Revision 1.2 1998/03/02 23:38:40 latex2html# Reworked configuration procedure substantially. Fixed some killing bugs.# Should now run on Win32, too.# The file prefs.pm contains user-configurable stuff for DOS platforms.# UNIX users can override the settings with the configure utility (preferred).## Revision 1.1 1998/02/14 19:31:55 latex2html# Preliminary checkin of configuration procedure## (end CVS log)################################################################################ This file has been automatically generated by build.pl from pstoimg.pin# Do not edit this file as your changes will be lost when reconfiguring.# If you want to supply patches, please apply them to pstoimg.pin and send# the diff relative to the original pstoimg.pin. Thank you.=head1 NAMEpstoimg - Convert a PostScript file to a bitmap image using Ghostscript and the Netpbm utilities=cutuse 5.003;use strict;#use diagnostics;use vars qw(*SAVEERR $LATEX2HTMLDIR $SCRIPT);# This variable points to the DIRECTORY where the latex2html files# can be found.use Getopt::Long;# see below for a description of the environmentBEGIN { # print "scanning for l2hdir\n"; if($ENV{LATEX2HTMLDIR}) { $LATEX2HTMLDIR = $ENV{LATEX2HTMLDIR}; } else { $ENV{LATEX2HTMLDIR} = $LATEX2HTMLDIR = '/usr/share/latex2html'; } if(-d $LATEX2HTMLDIR) { push(@INC,$LATEX2HTMLDIR); } else { die qq{Fatal: Directory "$LATEX2HTMLDIR" does not exist.\n}; }}use L2hos; # load OS-specific stuffmy $RELEASE = '2K.1beta';my ($VERSION) = q$Revision: 1.11 $ =~ /:\s*(\S+)/;$| = 1; # unbuffer STDOUTmy $dd = L2hos->dd; # Directory delimitermy $prompt;($prompt = $0) =~ s|^.*[/\\]||;# Configuration as determined by "configure"## Ghostscriptmy $GS = '/usr/bin/gs';my $GSDEVICE = 'pnmraw';my $GSALIASDEVICE = 'ppmraw';# Supported format(s)my @IMAGE_TYPES = qw(png);# Netpbmmy $PNMCROP = '/usr/bin/pnmcrop';my $PPMQUANT = '/usr/bin/ppmquant';my $PNMFLIP = '/usr/bin/pnmflip';my $PNMCAT = '/usr/bin/pnmcat';my $PNMFILE = '/usr/bin/pnmfile';my $PBMMAKE = '/usr/bin/pbmmake';# PNG supportmy $PNMTOPNG = '/usr/bin/pnmtopng';# Temporary diskspacemy $def_tmp = '/tmp'; # Space for temporary files# Some lengths used by dvips# MRO: Is this true for all runs of dvips?my $PAGE_HEIGHT = 841.889; # dvips page height, in pts.my $PAGE_WIDTH = 595.275; # dvips page width, in pts.my $PAGE_HMARGIN = 72; # dvips margin: 1 inch = 72ptmy $PAGE_VMARGIN = 72; # dvips margin: 1 inch = 72pt# The color to be made transparentmy $trans_color = '#ffffff';################################################################################ Default settings# Environment overrides defaults, command line options override everythingunless(@ARGV) { print_help(); exit 0; }=head1 SYNOPSISB<pstoimg> B<-help> | B<-version>B<pstoimg>S<[ B<-antialias> ]>S<[ B<-aaliastext> ]>S<[ B<-center> I<num> ]>S<[ B<-color> I<num> ]>S<[ B<-crop> I<code> ]>S<[ B<-debug> ]>S<[ B<-density> I<num>]>S<[ B<-depth> I<num> ]>S<[ B<-discard> ]>S<[ B<-flip> I<code> ]>S<[ B<-geometry> I<X>xI<Y> ]>S<[ B<-interlaced> ]>S<[ B<-margins> I<X>,I<Y> ]>S<[ B<-multipage> ]>S<[ B<-out> I<file> ]>S<[ B<-quiet> ]>S<[ B<-rightjustify> I<num> ]>S<[ B<-scale> I<num> ]>S<[ B<-tmp> I<path> ]>S<[ B<-topjustify> [B<x>]I<num> ]>S<[ B<-transparent> ]>S<[ B<-type> I<type> ]>S<[ B<-shoreup> I<num>[B<d>] ]>S<[ B<-white> ]>I<file>S<[ I<file2> ... ]>=cutmy %opt = ();unless(&GetOptions(\%opt, qw(-help -version -debug -discard -antialias -aaliastext -multipage -type=s -gif -png -out=s -depth=i -color=i -flip=s -density=i -scale=f -geometry=s -margins=s -crop=s -transparent -interlaced -rightjustify=i -center=i -topjustify=s -shoreup=s -tmp=s -white -quiet))) { print_usage("$prompt: Error: Invalid option(s) specified."); exit 1;}=head1 OPTIONSThe command line options may be abbreviated to the shortest uniqueprefix.=over 4=item B<-help>Show this help page and exit.=cutif($opt{help}) { print_help(); exit 0; }=item B<-version>Show the release and version of pstoimg and exit.=cutif($opt{version}) { print_version(); exit 0; }banner() unless($opt{quiet});=item B<-antialias>Use Ghostscript's anti-aliasing feature for rendering "softer" images.This applies to lines and edges of polygonal and oval or circular shapes.Only valid if Ghostscipt 4.03 or higher is installed.=item B<-aaliastext>Use Ghostscript's anti-aliasing feature for "smoother" font characters,without the jagged edges. Similar to B<-antialias> for graphic components.Only valid if Ghostscipt 4.03 or higher is installed.=item B<-center> I<num>Add the appropriate amount of whitespace to the left of the image sothat the image appears to be centered in a total width of I<num> pixels.=cutmy $CENTER = 0; # No centering by defaultif($opt{center}) { $CENTER = $opt{center}; die <<"EOF" unless ($CENTER =~ /^\d+$/ && $CENTER > 0);$prompt: Error: Illegal width for -center specified: "$CENTER" Value must be a positive integer.EOF }=item B<-crop> I<code>Crop the bitmap from the given directions. I<code> may be a string ofseveral cropping instructions, which are executed strictly in the givenorder. Possible values are: B<h> (horizontal, i.e. crop top andbottom), B<v> (vertical), B<tblr> (top, bottom, left, right) and B<a> (alldirections). A special case is B<s>: "shave" the image at the bottom, but onlyif a single line of whitespace exists.=cutmy $EXTRA_CROP = '';if($opt{crop}) { $EXTRA_CROP = lc($opt{crop}); die <<"EOF" unless ( $EXTRA_CROP =~ /^([vhtblras]+)$/i );$prompt: Error: Illegal crop specified: "$EXTRA_CROP" Crop must be h, v, t, b, l, r, a, s or combinationEOF }=item B<-debug>Turn on debugging output. This can get rather verbose. Any intermediatefiles generated are not removed to help debugging.=cutif($ENV{DEBUG}) { $opt{debug} = 1; }=item B<-density> I<num>The density (resolution) in DPI in which to render the bitmap. The defaultis 72.=cutmy $DENSITY = 72;if($opt{density}) { $DENSITY = $opt{density}; }elsif($ENV{DENSITY}) { $DENSITY = $ENV{DENSITY}; }die <<"EOF" unless $DENSITY =~ /^\d+$/;$prompt: Error: Illegal density specified: "$DENSITY" Density must be an integer value. Default is 72.EOF=item B<-depth> I<num> or B<-color> I<num>Specify the color depth of the bitmap. Legal values are 1 (black & white),8 (256 colors) and 24 (true color).=cutunless($opt{depth}) { if($opt{color}) { $opt{depth} = $opt{color}; } elsif($ENV{DEPTH}) { $opt{depth} = $ENV{DEPTH}; } else { $opt{depth} = 8; } }die <<"EOF" unless $opt{depth} =~ /^(1|8|24)$/;$prompt: Error: Illegal color depth specified: "$opt{depth}" Depth must be either 1, 8 or 24.EOF=item B<-discard>Delete the input postscript file if the conversion was successful. Settingthe environment DISCARD to a true value (as perl sees it) has the sameeffect.=cutif($ENV{DISCARD}) { $opt{discard} = 1; }=item B<-flip> I<code>Flip all generated output bitmaps. The following codes are recognized:lr (flip left-right), tb (flip top-bottom), xy (flip bottom/left-top/right),r90 and ccw (rotate by 90 degrees counterclockwise), r270 and cw (rotate90 degrees clockwise) and r180 (rotate 180 degrees).=cutif($opt{flip}) { $opt{flip} = lc($opt{flip}); die <<"EOF" unless $opt{flip} =~ /^(lr|tb|xy|r90|ccw|r270|cw|r180)$/;$prompt: Error: Illegal flip option specified: "$opt{flip}" Flip must be one of: lr tb xy r90 ccw r270 cw r180EOF }=item B<-geometry> I<X>xI<Y>Render only this "window" of the PostScript file. If given, this optioncan dramatically reduce memory requirements and speed up conversion. Thegeometry is automatically detected in case of EPS files (EncapsulatedPostScript).=cutmy $GEOMETRY = '';if($opt{geometry}) { $GEOMETRY = $opt{geometry}; if($GEOMETRY =~ s/-//o ) { $EXTRA_CROP .= 'bl'; } die <<"EOF" unless ($GEOMETRY =~ /^\d+x\d+$/i);$prompt: Error: Illegal geometry specified: "$GEOMETRY" Geometry must be <width>x<height>EOF }=item B<-interlaced>Generate an interlaced bitmap. Interlaced images build up from coarse to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -