- Modifications to compile ImageMagick

This commit is contained in:
Santi Noreña 2013-02-19 18:37:48 +01:00
parent 615ec83706
commit 83522c16c3
3442 changed files with 57 additions and 412926 deletions

View file

@ -0,0 +1,250 @@
#
# Top Makefile for Magick++
#
# Copyright Bob Friesenhahn, 1999, 2000, 2002, 2004
#
if WITH_MAGICK_PLUS_PLUS
magickppincdir = $(INCLUDE_PATH)/Magick++
MAGICKPP_LIBS = Magick++/lib/libMagick++.la
MAGICKPP_SCRPTS = \
Magick++/bin/Magick++-config
MAGICKPP_MANS = \
Magick++/bin/Magick++-config.1
MAGICKPP_PKGCONFIG = \
Magick++/lib/ImageMagick++.pc
MAGICKPP_TESTS = \
Magick++/tests/exceptions.sh \
Magick++/tests/appendImages.sh \
Magick++/tests/attributes.sh \
Magick++/tests/averageImages.sh \
Magick++/tests/coalesceImages.sh \
Magick++/tests/coderInfo.sh \
Magick++/tests/colorHistogram.sh \
Magick++/tests/color.sh \
Magick++/tests/montageImages.sh \
Magick++/tests/morphImages.sh \
Magick++/tests/readWriteBlob.sh \
Magick++/tests/readWriteImages.sh \
Magick++/demo/analyze.sh \
Magick++/demo/button.sh \
Magick++/demo/demo.sh \
Magick++/demo/flip.sh \
Magick++/demo/gravity.sh \
Magick++/demo/piddle.sh \
Magick++/demo/shapes.sh \
Magick++/demo/zoom_bessel.sh \
Magick++/demo/zoom_blackman.sh \
Magick++/demo/zoom_box.sh \
Magick++/demo/zoom_catrom.sh \
Magick++/demo/zoom_cubic.sh \
Magick++/demo/zoom_gaussian.sh \
Magick++/demo/zoom_hamming.sh \
Magick++/demo/zoom_hanning.sh \
Magick++/demo/zoom_hermite.sh \
Magick++/demo/zoom_lanczos.sh \
Magick++/demo/zoom_mitchell.sh \
Magick++/demo/zoom_point.sh \
Magick++/demo/zoom_quadratic.sh \
Magick++/demo/zoom_sample.sh \
Magick++/demo/zoom_scale.sh \
Magick++/demo/zoom_sinc.sh \
Magick++/demo/zoom_triangle.sh
MAGICKPP_EXTRA_DIST = \
Magick++/AUTHORS \
Magick++/COPYING \
Magick++/ChangeLog \
Magick++/INSTALL \
Magick++/NEWS \
Magick++/README \
Magick++/bin/Magick++-config.1 \
Magick++/bin/Magick++-config.in \
Magick++/lib/ImageMagick++.pc.in \
Magick++/demo/model.miff \
Magick++/demo/smile.miff \
Magick++/demo/smile_anim.miff \
Magick++/demo/tile.miff \
$(MAGICKPP_TESTS) \
Magick++/tests/test_image.miff \
Magick++/tests/test_image_anim.miff
MAGICKPP_CLEANFILES = \
Magick++/demo/*_out.* \
Magick++/demo/ir.out \
Magick++/tests/colorHistogram.txt \
Magick++/tests/testmagick_anim_out.miff \
Magick++/tests/ir.out
Magick___lib_libMagick___la_SOURCES = \
Magick++/lib/Blob.cpp \
Magick++/lib/BlobRef.cpp \
Magick++/lib/CoderInfo.cpp \
Magick++/lib/Color.cpp \
Magick++/lib/Drawable.cpp \
Magick++/lib/Exception.cpp \
Magick++/lib/Functions.cpp \
Magick++/lib/Geometry.cpp \
Magick++/lib/Image.cpp \
Magick++/lib/ImageRef.cpp \
Magick++/lib/Montage.cpp \
Magick++/lib/Options.cpp \
Magick++/lib/Pixels.cpp \
Magick++/lib/STL.cpp \
Magick++/lib/Thread.cpp \
Magick++/lib/TypeMetric.cpp \
Magick++/lib/Magick++.h \
Magick++/lib/Magick++/Blob.h \
Magick++/lib/Magick++/BlobRef.h \
Magick++/lib/Magick++/CoderInfo.h \
Magick++/lib/Magick++/Color.h \
Magick++/lib/Magick++/Drawable.h \
Magick++/lib/Magick++/Exception.h \
Magick++/lib/Magick++/Functions.h \
Magick++/lib/Magick++/Geometry.h \
Magick++/lib/Magick++/Image.h \
Magick++/lib/Magick++/ImageRef.h \
Magick++/lib/Magick++/Include.h \
Magick++/lib/Magick++/Montage.h \
Magick++/lib/Magick++/Options.h \
Magick++/lib/Magick++/Pixels.h \
Magick++/lib/Magick++/STL.h \
Magick++/lib/Magick++/Thread.h \
Magick++/lib/Magick++/TypeMetric.h
magickpptopincdir = $(INCLUDE_PATH)
magickpptopinc_HEADERS = \
Magick++/lib/Magick++.h
magickppinc_HEADERS = \
Magick++/lib/Magick++/Blob.h \
Magick++/lib/Magick++/CoderInfo.h \
Magick++/lib/Magick++/Color.h \
Magick++/lib/Magick++/Drawable.h \
Magick++/lib/Magick++/Exception.h \
Magick++/lib/Magick++/Geometry.h \
Magick++/lib/Magick++/Image.h \
Magick++/lib/Magick++/Include.h \
Magick++/lib/Magick++/Montage.h \
Magick++/lib/Magick++/Pixels.h \
Magick++/lib/Magick++/STL.h \
Magick++/lib/Magick++/TypeMetric.h
Magick___lib_libMagick___la_LDFLAGS = $(MAGICK_LT_RELEASE_OPTS) \
-version-info $(MAGICK_LIBRARY_CURRENT):$(MAGICK_LIBRARY_REVISION):$(MAGICK_LIBRARY_AGE)
Magick___lib_libMagick___la_LIBADD = $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS)
MAGICKPP_CHECK_PGRMS = \
Magick++/demo/analyze \
Magick++/demo/button \
Magick++/demo/demo \
Magick++/demo/detrans \
Magick++/demo/flip \
Magick++/demo/gravity \
Magick++/demo/piddle \
Magick++/demo/shapes \
Magick++/demo/zoom \
Magick++/tests/appendImages \
Magick++/tests/attributes \
Magick++/tests/averageImages \
Magick++/tests/coalesceImages \
Magick++/tests/coderInfo \
Magick++/tests/color \
Magick++/tests/colorHistogram \
Magick++/tests/exceptions \
Magick++/tests/montageImages \
Magick++/tests/morphImages \
Magick++/tests/readWriteBlob \
Magick++/tests/readWriteImages
Magick___demo_analyze_SOURCES = Magick++/demo/analyze.cpp
Magick___demo_analyze_LDADD = $(MAGICKPP_LIBS)
Magick___demo_button_SOURCES = Magick++/demo/button.cpp
Magick___demo_button_LDADD = $(MAGICKPP_LIBS)
Magick___demo_demo_SOURCES = Magick++/demo/demo.cpp
Magick___demo_demo_LDADD = $(MAGICKPP_LIBS)
Magick___demo_detrans_SOURCES = Magick++/demo/detrans.cpp
Magick___demo_detrans_LDADD = $(MAGICKPP_LIBS)
Magick___demo_flip_SOURCES = Magick++/demo/flip.cpp
Magick___demo_flip_LDADD = $(MAGICKPP_LIBS)
Magick___demo_gravity_SOURCES = Magick++/demo/gravity.cpp
Magick___demo_gravity_LDADD = $(MAGICKPP_LIBS)
Magick___demo_piddle_SOURCES = Magick++/demo/piddle.cpp
Magick___demo_piddle_LDADD = $(MAGICKPP_LIBS)
Magick___demo_shapes_SOURCES = Magick++/demo/shapes.cpp
Magick___demo_shapes_LDADD = $(MAGICKPP_LIBS)
Magick___demo_zoom_SOURCES = Magick++/demo/zoom.cpp
Magick___demo_zoom_LDADD = $(MAGICKPP_LIBS)
Magick___tests_appendImages_SOURCES = Magick++/tests/appendImages.cpp
Magick___tests_appendImages_LDADD = $(MAGICKPP_LIBS)
Magick___tests_attributes_SOURCES = Magick++/tests/attributes.cpp
Magick___tests_attributes_LDADD = $(MAGICKPP_LIBS)
Magick___tests_averageImages_SOURCES = Magick++/tests/averageImages.cpp
Magick___tests_averageImages_LDADD = $(MAGICKPP_LIBS)
Magick___tests_coalesceImages_SOURCES = Magick++/tests/coalesceImages.cpp
Magick___tests_coalesceImages_LDADD = $(MAGICKPP_LIBS)
Magick___tests_coderInfo_SOURCES = Magick++/tests/coderInfo.cpp
Magick___tests_coderInfo_LDADD = $(MAGICKPP_LIBS)
Magick___tests_color_SOURCES = Magick++/tests/color.cpp
Magick___tests_color_LDADD = $(MAGICKPP_LIBS)
Magick___tests_colorHistogram_SOURCES = Magick++/tests/colorHistogram.cpp
Magick___tests_colorHistogram_LDADD = $(MAGICKPP_LIBS)
Magick___tests_exceptions_SOURCES = Magick++/tests/exceptions.cpp
Magick___tests_exceptions_LDADD = $(MAGICKPP_LIBS)
Magick___tests_montageImages_SOURCES = Magick++/tests/montageImages.cpp
Magick___tests_montageImages_LDADD = $(MAGICKPP_LIBS)
Magick___tests_morphImages_SOURCES = Magick++/tests/morphImages.cpp
Magick___tests_morphImages_LDADD = $(MAGICKPP_LIBS)
Magick___tests_readWriteBlob_SOURCES = Magick++/tests/readWriteBlob.cpp
Magick___tests_readWriteBlob_LDADD = $(MAGICKPP_LIBS)
Magick___tests_readWriteImages_SOURCES= Magick++/tests/readWriteImages.cpp
Magick___tests_readWriteImages_LDADD = $(MAGICKPP_LIBS)
MAGICKPP_LOCAL_TARGETS = www/Magick++/NEWS.html www/Magick++/ChangeLog.html
endif
if WITH_PERL
# Build HTML version of news
www/Magick++/NEWS.html: Magick++/NEWS
# @PERL@ $(top_srcdir)/scripts/txt2html -t 'Magick++ News' < $(srcdir)/NEWS > $(srcdir)/www/Magick++/NEWS.html
# echo "Please do a 'cvs commit www/Magick++/NEWS.html' to submit updated HTML file"
# Build HTML version of ChangeLog
www/Magick++/ChangeLog.html: Magick++/ChangeLog
# @PERL@ $(top_srcdir)/scripts/txt2html -t 'Magick++ ChangeLog' < $(srcdir)/ChangeLog > $(srcdir)/www/Magick++/ChangeLog.html
# echo "Please do a 'cvs commit www/Magick++/ChangeLog.html' to submit updated HTML file"
else
#all-local:
endif

View file

@ -0,0 +1,647 @@
#!/usr/bin/perl -w
#
# Format ImageMagick comments into POD-format or HTML format
# documentation
# Produces *.pod or *.html files corresponding to *.c files
#
# Written by Bob Friesenhahn, April 1997
#
$opt_format='html';
$opt_srcdir='';
$opt_outdir='';
use Getopt::Long;
if ( ! GetOptions(
'format=s' => \$opt_format,
'srcdir=s' => \$opt_srcdir,
'outdir=s' => \$opt_outdir,
)
) {
print("Usage: fmtdocs [-srcdir srcdir] [-outdir outdir] [-format format] \n");
exit(1);
}
#
# Source files to use
#
@srcs = ('animate.c',
'annotate.c',
'attribute.c',
'blob.c',
'cache.c',
'cache-view.c',
'color.c',
'colorspace.c',
'compare.c',
'composite.c',
'constitute.c',
'decorate.c',
'deprecate.c',
'draw.c',
'drawing-wand.c',
'display.c',
'effect.c',
'enhance.c',
'exception.c',
'fx.c',
'image.c',
'list.c',
'magick.c',
'magick-wand.c',
'memory.c',
'monitor.c',
'montage.c',
'paint.c',
'pixel-iterator.c',
'pixel-wand.c',
'profile.c',
'quantize.c',
'registry.c',
'resource.c',
'segment.c',
'shear.c',
'signature.c',
'stream.c',
'transform.c',
'resize.c',
'version.c');
$tmpname_pre_format = "/tmp/fmtdocs_pre.$$";
$tmpname_pod = "/tmp/fmtdocs_pod.$$";
$tmpname_html = "/tmp/fmtdocs_html.$$";
#@srcs = ('draw.c');
#
# What is for source files
#
%whatis =
(
'animate', 'Interactively Animate an Image Sequence',
'annotate', 'Annotate an Image',
'attribute', 'Set Text Attributes',
'blob', 'Read or Write Binary Large OBjects',
'color', 'Count the Colors in an Image',
'colorspace', 'Dealing with Image Colorspaces',
'compare', 'Compare an Image to a Reconstructed Image',
'constitute', 'Constitute an Image',
'composite', 'Composite an Image',
'decorate', 'Decorate an Image',
'deprecate', 'Deprecated Methods',
'display', 'Interactively Display and Edit an Image',
'draw', 'Draw on an Image',
'drawing_wand', 'Image Vector Drawing',
'effect', 'Add an Effect',
'fx', 'Add a Special Effect',
'enhance', 'Enhance an Image',
'exception', 'Dealing with Exceptions',
'image', 'Image Methods',
'list', 'Working with Image Lists',
'cache', 'Get or Set Image Pixels',
'cache_view', 'Working with Cache Views',
'magick', 'Read or List Image formats',
'magick_wand', 'Magick Wand',
'memory', 'Memory Allocation',
'monitor', 'Monitor the Progress of an Image Operation',
'montage', 'Create an Image Thumbnail',
'paint', 'Paint on an Image',
'pixel_iterator', 'Pixel Iterator',
'pixel_wand', 'Pixel Wand',
'profile', 'Dealing with Image Profiles',
'quantize', 'Reduce the Number of Unique Colors in an Image',
'registry', 'The Registry',
'resource', 'Minitor or Limit Resource Consumption',
'segment', 'Segment an Image with Thresholding Fuzzy c-Means',
'shear', 'Shear or Rotate an Image by an Arbitrary Angle',
'signature', 'Compute a Digital Signature for an Image',
'stream', 'The Pixel FIFO',
'transform', 'Transform an Image',
'resize', 'Resize an Image',
'version', 'Get Version and Copyright',
);
#
# Key words to replace with HTML links
#
my %keywords =
(
AffineMatrix => 'types.html#AffineMatrix',
BlobInfo => 'types.html#BlobInfo',
Cache => 'types.html#Cache',
ChannelType => 'types.html#ChannelType',
ChromaticityInfo => 'types.html#ChromaticityInfo',
ClassType => 'types.html#ClassType',
ClipPathUnits => 'types.html#ClipPathUnits',
ColorPacket => 'types.html#ColorPacket',
ColorspaceType => 'types.html#ColorspaceType',
ComplianceType => 'types.html#ComplianceType',
CompositeOperator => 'types.html#CompositeOperator',
CompressionType => 'types.html#CompressionType',
DecorationType => 'types.html#DecorationType',
DrawContext => 'types.html#DrawContext',
DrawInfo => 'types.html#DrawInfo',
ErrorHandler => 'types.html#ErrorHandler',
ExceptionInfo => 'types.html#ExceptionInfo',
ExceptionType => 'types.html#ExceptionType',
FillRule => 'types.html#FillRule',
FilterTypes => 'types.html#FilterTypes',
FrameInfo => 'types.html#FrameInfo',
GravityType => 'types.html#GravityType',
Image => 'types.html#Image',
ImageInfo => 'types.html#ImageInfo',
ImageType => 'types.html#ImageType',
InterlaceType => 'types.html#InterlaceType',
LayerType => 'types.html#LayerType',
MagickInfo => 'types.html#MagickInfo',
MonitorHandler => 'types.html#MonitorHandler',
MontageInfo => 'types.html#MontageInfo',
NoiseType => 'types.html#NoiseType',
PaintMethod => 'types.html#PaintMethod',
PixelPacket => 'types.html#PixelPacket',
PointInfo => 'types.html#PointInfo',
ProfileInfo => 'types.html#ProfileInfo',
QuantizeInfo => 'types.html#QuantizeInfo',
Quantum => 'types.html#Quantum',
QuantumType => 'types.html#QuantumType',
RectangleInfo => 'types.html#RectangleInfo',
RegistryType => 'types.html#RegistryType',
RenderingIntent => 'types.html#RenderingIntent',
ResolutionType => 'types.html#ResolutionType',
ResourceType => 'types.html#ResourceType',
SegmentInfo => 'types.html#SegmentInfo',
SignatureInfo => 'types.html#SignatureInfo',
StorageType => 'types.html#StorageType',
StreamHandler => 'types.html#StreamHandler',
StretchType => 'types.html#StretchType',
StyleType => 'types.html#StyleType',
TypeMetric => 'types.html#TypeMetric',
CacheView => 'types.html#CacheView',
VirtualPixelMethod => 'types.html#VirtualPixelMethod',
XResourceInfo => 'types.html#XResourceInfo',
);
foreach $src (@srcs) {
my($out,$command);
# Compute POD name
($base = $src) =~ s/\.[^\.]*$//g;
$out = "${base}.${opt_format}";
if ("${opt_outdir}" ne "") {
$out = "${opt_outdir}/${base}.${opt_format}";
}
if ("${opt_srcdir}" ne "") {
$src = "${opt_srcdir}/${src}";
}
$command='pod2html -netscape';
if ( $opt_format eq 'html' ) {
$command='pod2html -netscape';
} elsif ( $opt_format eq 'latex' ) {
$command='pod2latex';
} elsif ( $opt_format eq 'man' ) {
$command='pod2man';
} elsif ( $opt_format eq 'text' ) {
$command='pod2text';
} elsif ( $opt_format eq 'pod' ) {
$command='cat';
}
print( "Processing $src -> $out\n" );
pre_format($src, $tmpname_pre_format); # Make easily parsed
format_to_pod($tmpname_pre_format, $tmpname_pod); # Format to pod.
if ( $opt_format eq 'html' ) {
system("$command $tmpname_pod > \"$tmpname_html\"");
reformat_html($tmpname_html,$out);
} else {
system("$command $tmpname_pod > \"$out\"");
}
unlink($tmpname_pre_format);
unlink($tmpname_pod);
unlink($tmpname_html);
}
#unlink($tmpname_pre_format);
exit(0);
#
# Reformat pod2html-generated HTML into nicer form.
#
sub reformat_html {
my($infile, $outfile) = @_;
open( IN, "<$infile" ) || die("Failed to open \"$infile\" for read\n" );
open( OUT, ">$outfile" ) || die("Failed to open \"$outfile\" for write\n" );
INPUT:
while(<IN>) {
s|<\!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">|<\!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">|;
s|<HEAD>|<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<STYLE>
<!--
\@page { size: 8.5in 11in }
TD P { color: #000000; font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-size: 12pt }
P { color: #000000; font-family: "Verdana", "Arial", "Helvetica", sans-serif; font-size: 12pt }
H2 { color: #000000 }
A:link { color: #0085c0 }
A:visited { color: #800080 }
-->
</STYLE>
|;
s|<link rev="made" href="mailto:root\@localhost" />|<link rel="stylesheet" type="text/css" href="../magick.css">|;
s|<body style="background-color: white">|<body marginheight="1" marginwidth="1" topmargin="1" leftmargin="1">
<a name="top"></a>
<table border="0" cellpadding="0" cellspacing="0" summary="Masthead" width="100%">
<tbody>
<tr>
<td bgcolor="#003399" width="25%" height="118" background="../../images/background.gif"><a href="http://www.imagemagick.org/"><img src="../../images/script.gif" width="278" height="118" border="0" alt="" /></a></td>
<td bgcolor="#003399" width="60%" height="118" background="../../images/background.gif"><a href="http://www.networkeleven.com/direct.php?magick_all"><img src="../../images/promote.png" border="0" width="186" height="52" vspace="29" alt="Powered by NetworkEleven" /></a></td>
<td bgcolor="#003399" width="114" height="118" align="right"><img src="../../images/sprite.png" width="114" height="118" alt="" /></td>
<td bgcolor="#003399" width="114" height="118" align="right"><a href="http://www.imagemagick.net"><img src="../../images/logo.png" width="114" height="118" border="0" alt="ImageMagick logo" /></a></td>
</tr></tbody></table>
<table align="left" border="0" cellpadding="2" cellspacing="2" summary="Navigation buttons" width="20%">
<tr>
<td>
<form target="_self" action="../../index.html"><input type="submit" title="ImageMagick Home" value=" Home" style="background-color: #1947A3; background-image:url('../../../images/background.gif'); color:#fbc713; font-weight:bold"></form></td>
<td>
<form target="_self" action="../../www/apis.html"><input type="submit" title="ImageMagick API" value=" API " style="background-color: #1947A3; background-image:url('../../../images/background.gif'); color:#fbc713; font-weight:bold"></form></td>
<td>
<form target="_self" action="../../www/download.html"><input type="submit" title="ImageMagick Download" value="Download" style="background-color: #1947A3; background-image:url('../../../images/background.gif'); color:#fbc713; font-weight:bold"></form></td></tr></table>
<div align="right" style="margin-top:3px; padding-right:4px">
<form action="http://studio.imagemagick.org/Sage/scripts/Sage.cgi"><input type="TEXT" name="query" size="32" maxlength="255"> <input type="SUBMIT" name="sa" value="Search" style="background-color: #1947A3; background-image:url('../../../images/background.gif'); bgcolor:#003399; color:#fbc713; font-weight:bold"></form></div>
<table align="left" border="0" cellpadding="10" cellspacing="0" style="margin-top:-17px" width="100%">
<tr>
<td>
|;
s|</body>|
<HR>
<a href="#top"><img src="../../../images/top.gif" border=0 width="35" height="46" align="right" alt="Top of page"></a>
<form action="http://studio.imagemagick.org/magick/" style="margin-top:5px">
<input type="submit" title="Help!" value="Help!" style="background-image:url('../../../images/background.gif'); color:#fbc713; font-weight:bold">
<small>&quot;Image manipulation software that works like magick&quot;</small>
</form></td>
</tr></table>
</body>
|;
s|<FONT SIZE=-1>||g;
s|</FONT>||g;
s|<H2>|<H3>|g;
s|</H2>|</H3>|g;
s|<H1>|<H2>|g;
s|</H1>|</H2>|g;
s|<DT>|<DD><P></P><DT>|g;
s|<DL>|<DL><DT><DD><DL>|g;
s|</DL>|</DL></DL>|g;
s|<dd>|<DD>|g;
s|<p>|<P>|g;
s|</p>|</P>|g;
s|</LI>||g;
s|>o |>|g;
s|unsignedint|unsigned int|g;
print( OUT $_ );
}
close( TMP );
close( IN );
}
#
# Pre-process file into intermediate form
#
# Initializes globals:
#
# @functions - Function names
# %synopsis - Function synopsis
#
sub pre_format {
my($infile, $tmpfile) = @_;
my $inpara = 0; # Set to 1 if in paragraph
my $inlist = 0; # Set to 1 if in list-item paragraph
# Open C source file
open( IN, "<$infile" ) || die("Failed to open \"$infile\" for read\n" );
# Open TMP file
open( TMP, ">$tmpfile" ) || die("Failed to open \"$tmpfile\" for write\n" );
undef @functions;
undef %synopsis;
# Skip past first form feed
while(<IN>) {
last if m/\014/;
}
LINE:
while(<IN>) {
if (m/^\+/) {
while(<IN>) {
last unless m/^%/;
}
next;
}
next unless m/^%/ ;
chop;
# Extract and save function title
if (m/^%\s+((\w )+)\s+%/) {
($ftitle = $1) =~ s/ //g;
push(@functions, $ftitle);
print( TMP "===$ftitle\n" );
next;
}
# Zap text we don't want
next if ( m/^%.+%/ ); # "%*%
s/^%\s{0,2}//;
# Extract and save synopsis info
if (m /\(\)/ ) {
# nothing
;
}
elsif ( m/${ftitle}\(.*\)$/ ) {
s/,/ , /g;
s/\(/ ( /g;
s/\)/ ) /g;
s/\*/ * /g;
s/\s+/ /g;
s/\(\s+\*/(*/g;
s/ ,/,/g;
s/ \(/(/g;
s/\) /)/g;
s/ \* / */g;
s/^\s*//;
$synopsis{$ftitle} = $_ . ';'; # Append semi-colon, prototype style
print ( TMP " " . $synopsis{$ftitle} . "\n" );
next LINE;
}
elsif ( m/${ftitle}\(.*/ ) {
$synopsis{$ftitle} = $_;
do {
$_ = <IN>;
chop;
# Zap text we don't want
next if m/^%.+%/; # "%*%
s/^%\s{0,2}//;
$synopsis{$ftitle} .= $_;
} until m/^\s*$/;
$_ = $synopsis{$ftitle};
s/,/ , /g;
s/\(/ ( /g;
s/\)/ ) /g;
s/\*/ * /g;
s/\s+/ /g;
s/\(\s+\*/(*/g;
s/ ,/,/g;
s/ \(/(/g;
s/\) /)/g;
s/ \* / */g;
s/^\s*//;
$synopsis{$ftitle} = $_ . ';'; # Append semi-colon, prototype style
print ( TMP " " . $synopsis{$ftitle} . "\n" );
next LINE;
}
# Keep track of paragraphing
if( ! m/^$/ ) {
if ( $inpara == 0 ) {
$inpara = 1; # Start of paragraph
$para = "$_"; # Start paragraph string
} else {
# Inside paragraph
$para .= " $_"; # Add line to paragraph
}
}
# Keep track of list items so they can
# be wrapped as a paragraph
if( m/^\s+(o[^:]+:|o|[0-9]\.)\s(.*)/ ) {
$inlist = 1;
}
if ( $inpara == 1 ) {
if( $para =~ m/^\s+\S+/ && ! $inlist ) {
# Lines that start with a space shouldn't be munged
$inpara = 0; # End of paragraph
$inlist = 0;
$para .= ""; # Terminate paragraph
print( TMP "$para\n" );
}
elsif( m/^$/ ) {
# End of paragraph
$inpara = 0; # End of paragraph
$inlist = 0;
$para .= ""; # Terminate paragraph
$para =~ s/^\s+//g; # Eliminate any leading space
$para =~ s/\s+/ /g; # Canonicalize whitespace
$para =~ s/ $//; # Trim final space
$para =~ s/([a-zA-Z0-9][.!?][)'"]*) /$1 /g; #' Fix sentance ends
print( TMP "\n$para\n\n" );
}
}
}
close( TMP );
close( IN );
}
#
# Second pass
# Process into formatted form
#
sub format_to_pod {
my($infile, $outfile) = @_;
my $func;
my $inlist = 0; # Set to one if in indented list
# Open input file
open( IN, "<$infile" ) || die("Failed to open \"$infile\" for read\n" );
# Open output file
open( OUT, ">$outfile" ) || die("Failed to open \"$outfile\" for write\n" );
# Name field
print( OUT head1("NAME") );
if (!defined($whatis{$base})) {
print("Whatis definition missing for \"$base\"!\n");
print( OUT "${base} - Unknown\n\n" );
} else {
print( OUT "${base} - $whatis{$base}\n\n" );
}
# Synopsis field (function signatures)
print( OUT head1("SYNOPSIS") );
foreach $func (sort( @functions )) {
if (defined $synopsis{$func} ) {
$_ = $synopsis{$func};
s/$func/ B<$func>/;
s/^\s*//;
my $synopsis = $_;
print( OUT $synopsis, "\n\n" );
}
}
# Description field
print( OUT head1("FUNCTION DESCRIPTIONS") );
while(<IN>){
chop;
next if m/^$/;
# Match list element
if( m/^(o[^:]+:|o|[0-9]\.?)\s(.*)/ ) {
my $bullet = $1;
my $bullet_text = $2;
print( OUT startlist() ) unless $inlist;
$inlist = 1;
print( OUT item($bullet), "$bullet_text\n\n" );
next;
} else {
print( OUT endlist() ) if $inlist;
$inlist = 0;
}
# Match synopsis item
if( defined $func && m/$func\s*\(.*\)/ ) {
# Split all words with spaces to aid with tokenization
s/,/ , /g;
s/\(/ ( /g;
s/\)/ ) /g;
s/\*/ * /g;
my $html = '';
# Replace tokens matching keywords with HTML links.
TOKEN: foreach $token ( split(' ', $_ ) ) {
foreach $keyword ( %keywords ) {
if ( $token eq $keyword ) {
$html .= linked( $keyword, $keywords{$keyword} );
$html .= " ";
next TOKEN;
}
}
$html .= "$token ";
}
$_ = $html;
# Remove excess spaces
s/\s+/ /g;
s/ ,/,/g;
s/\* /*/g;
s/\)\s*\;/);/;
s/^\s*//;
s/ \( *\)/\(\)/;
# This is very poor because text is output specifically
# for HTML so the text isn't output at all for other target
# formats.
print( OUT html("<blockquote>$_</blockquote>") );
next;
}
# Match function title
if( m/===([a-zA-Z0-9]+)/ ) {
$func = $1;
print( OUT head2($func) );
next;
}
print( OUT "\n") if /^[^ ]/;
print( OUT "$_\n") ;
print( OUT "\n") if /^[^ ]/;
}
close( OUT );
close( IN );
}
#
# Return level 1 heading
# Similar to: <H1>heading</H1>
#
sub head1 {
my($heading) = @_;
return( "=head1 $heading\n\n" );
}
#
# Return level 2 heading
# Similar to: <H2>heading</H2>
#
sub head2 {
my($heading) = @_;
return( "=head2 $heading\n\n" );
}
#
# Return item
# Simlar to: <I>
#
sub item {
my($item) = @_;
return( "=item $item\n\n" );
}
#
# Start list
# Similar to: <UL>
#
sub startlist {
return( "=over 4\n\n" )
}
#
# End list
# Similar to: </UL>
#
sub endlist {
return( "=back\n\n" );
}
#
# Preformatted text
# Similar to <PRE></PRE>
#
sub formated {
my($text) = @_;
return( " $text\n\n" );
}
#
# Raw HTML paragraph
#
sub html {
my($html) = @_;
return return( "=for html $html\n\n" );
}
#
# HTML Link
# Similar to: <A HREF="url">description</A>
#
sub linked {
local($description, $url) = @_;
return( "<A HREF=\"" . $url . "\">" . $description . "</A>" );
}

969
ImageMagick/scripts/txt2html Executable file
View file

@ -0,0 +1,969 @@
#!/usr/bin/perl
eval 'exec perl -S $0 "$@"'
if $runnning_under_some_shell;
#
# txt2html.pl
# Convert raw text to something with a little HTML formatting
#
# Written by Seth Golub <seth@cs.wustl.edu>
# http://www.cs.wustl.edu/~seth/txt2html/
#
# $Revision: 1.15 $
# $Date: 2004/10/05 20:30:33 $
# $Author: cristy $
#
#
# $Log: txt2html,v $
# Revision 1.15 2004/10/05 20:30:33 cristy
# *** empty log message ***
#
# Revision 1.14 2004/04/26 19:53:42 cristy
# *** empty log message ***
#
# Revision 1.13 2004/04/26 15:03:00 cristy
# *** empty log message ***
#
# Revision 1.12 2004/04/24 13:48:50 cristy
# *** empty log message ***
#
# Revision 1.11 2003/10/28 18:40:59 cristy
# *** empty log message ***
#
# Revision 1.10 2003/10/28 03:44:38 cristy
# *** empty log message ***
#
# Revision 1.9 2003/10/17 13:59:12 cristy
# *** empty log message ***
#
# Revision 1.8 2003/10/16 22:26:06 cristy
# *** empty log message ***
#
# Revision 1.7 2003/10/12 04:10:15 cristy
# *** empty log message ***
#
# Revision 1.6 2003/07/20 03:39:50 cristy
# *** empty log message ***
#
# Revision 1.5 2003/07/19 19:44:20 cristy
# *** empty log message ***
#
# Revision 1.4 2003/04/07 23:35:40 cristy
# *** empty log message ***
#
# Revision 1.3 2003/04/05 02:52:42 cristy
# *** empty log message ***
#
# Revision 1.2 2003/04/04 20:50:50 cristy
# *** empty log message ***
#
# Revision 1.1 2003/03/25 15:10:23 cristy
# genesis
#
# Revision 1.1 2003/03/22 17:02:00 cristy
# *** empty log message ***
#
# Revision 1.10 1994/12/28 20:10:25 seth
# * Added --extract, etc.
#
# Revision 1.9 94/12/13 15:16:23 15:16:23 seth (Seth Golub)
# * Changed from #!/usr/local/bin/perl to the more clever version in
# the man page. (How did I manage not to read this for so long?)
# * Swapped hrule & header back to handle double lines. Why should
# this order screw up headers?
#
# Revision 1.8 1994/11/30 21:07:03 seth
# * put mail_anchor back in. (Why did I take this out?)
# * Finally added handling of lettered lists (ordered lists marked with
# letters)
# * Added title option (--title, -t)
# * Shortline now looks at how long the line was before txt2html
# started adding tags. ($line_length)
# * Changed list references to scalars where appropriate. (@foo[0] -> $foo[0])
# * Added untabify() to homogenize leading indentation for list
# prefixes and functions that use line length
# * Added "underline tolerance" for when underlines are not exactly the
# same length as what they underline.
# * Added error message for unrecognized options
# * removed \w matching on --capstag
# * Tagline now removes leading & trailing whitespace before tagging
# * swapped order of caps & heading in main loop
# * Cleaned up code for speed and to get rid of warnings
# * Added more restrictions to something being a mail header
# * Added indentation for lists, just to make the output more readable.
# * Fixed major bug in lists: $OL and $UL were never set, so when a
# list was ended "</UL>" was *always* used!
# * swapped order of hrule & header to properly handle long underlines
#
# Revision 1.7 94/10/28 13:16:11 13:16:11 seth (Seth Golub)
# * Added to comments in options section
# * renamed blank to is_blank
# * Page break is converted to horizontal rule <HR>
# * moved usage subroutine up top so people who look through code see
# it sooner
#
# Revision 1.6 94/10/28 12:43:46 12:43:46 seth (Seth Golub)
# * Creates anchors at each heading
#
# Revision 1.5 94/07/14 17:43:59 17:43:59 seth (Seth Golub)
# * Fixed minor bug in Headers
# * Preformatting can be set to only start/stop when TWO lines of
# [non]formatted-looking-text are encountered. Old behavior is still
# possible through command line options (-pb 1 -pe 1).
# * Can preformat entire document (-pb 0) or disable preformatting
# completely (-pe 0).
# * Fixed minor bug in CAPS handling (paragraph breaks broke)
# * Puts paragraph tags *before* paragraphs, not just between them.
#
# Revision 1.4 94/06/20 16:42:55 16:42:55 seth (Seth Golub)
# * Allow ':' for numbered lists (e.g. "1: Figs")
# * Whitespace at end of line will not start or end preformatting
# * Mailmode is now off by default
# * Doesn't break short lines if they are the first line in a list
# item. It *should* break them anyway if the next line is a
# continuation of the list item, but I haven't dealt with this yet.
# * Added action on lines that are all capital letters. You can change
# how these lines get tagged, as well as the mininum number of
# consecutive capital letters required to fire off this action.
#
# Revision 1.3 94/05/17 15:58:58 15:58:58 seth (Seth Golub)
# * Tiny bugfix in unhyphenation
#
# Revision 1.2 94/05/16 18:15:16 18:15:16 seth (Seth Golub)
# * Added unhyphenation
#
# Revision 1.1 94/05/16 16:19:03 16:19:03 seth (Seth Golub)
# Initial revision
#
#
# 1.02 Allow '-' in mail headers
# Added handling for multiline mail headers
#
#
#
# Oscar Nierstrasz has a nice script for hypertextifying URLs.
# It is available at:
# http://cui_www.unige.ch/ftp/PUBLIC/oscar/scripts/html.pl
#
#########################
# Configurable options
#
# [-s <n> ] | [--shortline <n> ]
$short_line_length = 40; # Lines this short (or shorter) must be
# intentionally broken and are kept
# that short. <BR>
# [-p <n> ] | [--prewhite <n> ]
$preformat_whitespace_min = 5; # Minimum number of consecutive leading
# whitespace characters to trigger
# preformatting.
# NOTE: Tabs are now expanded to
# spaces before this check is made.
# That means if $tab_width is 8 and
# this is 5, then one tab is expanded
# to 8 spaces, which is enough to
# trigger preformatting.
# [-pb <n> ] | [--prebegin <n> ]
$preformat_trigger_lines = 2; # How many lines of preformatted-looking
# text are needed to switch to <PRE>
# <= 0 : Preformat entire document
# 1 : one line triggers
# >= 2 : two lines trigger
# [-pe <n> ] | [--preend <n> ]
$endpreformat_trigger_lines = 2; # How many lines of unpreformatted-looking
# text are needed to switch from <PRE>
# <= 0 : Never preformat within document
# 1 : one line triggers
# >= 2 : two lines trigger
# NOTE for --prebegin and --preend:
# A zero takes precedence. If one is zero, the other is ignored.
# If both are zero, entire document is preformatted.
# [-r <n> ] | [--hrule <n> ]
$hrule_min = 4; # Min number of ---s for an HRule.
# [-c <n> ] | [--caps <n> ]
$min_caps_length = 3; # min sequential CAPS for an all-caps line
# [-ct <tag> ] | [--capstag <tag> ]
$caps_tag = "STRONG"; # Tag to put around all-caps lines
# [-m/+m ] | [--mail / --nomail ]
$mailmode = 0; # Deal with mail headers & quoted text
# [-u/+u ] | [--unhyphenate / --nounhyphenate ]
$unhyphenation = 1; # Enables unhyphenation of text.
# [-a <file> ] | [--append <file> ]
# [+a ] | [--noappend ]
$append_file = 0; # If you want something appended by
# default, put the filename here.
# The appended text will not be
# processed at all, so make sure it's
# plain text or decent HTML. i.e. do
# not have things like:
# Seth Golub <seth@cs.wustl.edu>
# but instead, have:
# Seth Golub &lt;seth@cs.wustl.edu&gt;
# [-t <title>] | [--title <title> ]
$title = 0; # You can specify a title.
# Otherwise it won't put one in.
# [-ul <n> ] | [--underlinelong <n> ]
$underline_tolerance_long = 1; # How much longer can underlines
# be and still be underlines?
# [-us <n> ] | [--underlineshort <n> ]
$underline_tolerance_short = 1; # How much shorter can underlines
# be and still be underlines?
# [-tw <n> ] | [--tabwidth <n> ]
$tab_width = 8; # How many spaces equal a tab?
# [-iw <n> ] | [--indent <n> ]
$indent_width = 2; # Indents this many spaces for each
# level of a list
# [-/+e ] | [--extract / --noextract ]
$extract = 0; # Extract Mode (suitable for inserting)
# END OF CONFIGURABLE OPTIONS
########################################
########################################
# Definitions (Don't change these)
#
$NONE = 0;
$LIST = 1;
$HRULE = 2;
$PAR = 4;
$PRE = 8;
$END = 16;
$BREAK = 32;
$HEADER = 64;
$MAILHEADER = 128;
$MAILQUOTE = 256;
$CAPS = 512;
$OL = 1;
$UL = 2;
sub usage
{
$0 =~ s#.*/##;
local($s) = " " x length($0);
print STDERR <<EOF;
Usage: $0 [options]
where options are:
$s [-v ] | [--version ]
$s [-h ] | [--help ]
$s [-s <n> ] | [--shortline <n> ]
$s [-p <n> ] | [--prewhite <n> ]
$s [-pb <n> ] | [--prebegin <n> ]
$s [-pe <n> ] | [--preend <n> ]
$s [-e/+e ] | [--extract / --noextract ]
$s [-r <n> ] | [--hrule <n> ]
$s [-c <n> ] | [--caps <n> ]
$s [-ct <tag> ] | [--capstag <tag> ]
$s [-m/+m ] | [--mail / --nomail ]
$s [-u/+u ] | [--unhyphen / --nounhyphen ]
$s [-a <file> ] | [--append <file> ]
$s [+a ] | [--noappend ]
$s [-t <title>] | [--title <title> ]
$s [-tw <n> ] | [--tabwidth <n> ]
$s [-iw <n> ] | [--indent <n> ]
$s [-ul <n> ] | [--underlinelong <n> ]
$s [-us <n> ] | [--underlineshort <n> ]
More complete explanations of these options can be found in
comments near the beginning of the script.
EOF
}
sub deal_with_options
{
while ($ARGV[0] =~ /^[-+].+/)
{
if (($ARGV[0] eq "-r" || $ARGV[0] eq "--hrule") &&
$ARGV[1] =~ /^%d+$/)
{
$hrule_min = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-s" || $ARGV[0] eq "--shortline") &&
$ARGV[1] =~ /^\d+$/)
{
$short_line_length = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-p" || $ARGV[0] eq "--prewhite") &&
$ARGV[1] =~ /^\d+$/)
{
$preformat_whitespace_min = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-pb" || $ARGV[0] eq "--prebegin") &&
$ARGV[1] =~ /^\d+$/)
{
$preformat_trigger_lines = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-pe" || $ARGV[0] eq "--preend") &&
$ARGV[1] =~ /^\d+$/)
{
$endpreformat_trigger_lines = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-e" || $ARGV[0] eq "--extract"))
{
$extract = 1;
shift @ARGV;
next;
}
if (($ARGV[0] eq "+e" || $ARGV[0] eq "--noextract"))
{
$extract = 0;
shift @ARGV;
next;
}
if (($ARGV[0] eq "-c" || $ARGV[0] eq "--caps") &&
$ARGV[1] =~ /^\d+$/)
{
$min_caps_length = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-ct" || $ARGV[0] eq "--capstag") &&
$ARGV[1])
{
$caps_tag = $ARGV[1];
shift @ARGV;
next;
}
if ($ARGV[0] eq "-m" || $ARGV[0] eq "--mail")
{
$mailmode = 1;
next;
}
if ($ARGV[0] eq "+m" || $ARGV[0] eq "--nomail")
{
$mailmode = 0;
next;
}
if ($ARGV[0] eq "-u" || $ARGV[0] eq "--unhyphen")
{
$unhyphenation = 1;
next;
}
if ($ARGV[0] eq "+u" || $ARGV[0] eq "--nounhyphen")
{
$unhyphenation = 0;
next;
}
if (($ARGV[0] eq "-a" || $ARGV[0] eq "--append") &&
$ARGV[1])
{
if (-r $ARGV[1]) {
$append_file = $ARGV[1];
} else {
print STDERR "Can't find or read $ARGV[1].\n";
}
shift @ARGV;
next;
}
if ($ARGV[0] eq "+a" || $ARGV[0] eq "--noappend")
{
$append_file = 0;
next;
}
if (($ARGV[0] eq "-t" || $ARGV[0] eq "--title") &&
$ARGV[1])
{
$title = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-ul" || $ARGV[0] eq "--underlinelong") &&
$ARGV[1] =~ /^\d+$/)
{
$underline_tolerance_long = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-us" || $ARGV[0] eq "--underlineshort") &&
$ARGV[1] =~ /^\d+$/)
{
$underline_tolerance_short = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-tw" || $ARGV[0] eq "--tabwidth") &&
$ARGV[1] =~ /^\d+$/)
{
$tab_width = $ARGV[1];
shift @ARGV;
next;
}
if (($ARGV[0] eq "-iw" || $ARGV[0] eq "--indentwidth") &&
$ARGV[1] =~ /^\d+$/)
{
$indent_width = $ARGV[1];
shift @ARGV;
next;
}
if ($ARGV[0] eq "-v" || $ARGV[0] eq "--version")
{
print '$Header: /users/hilco/seth/projects/txt2html/txt2html.pl,v 1
.10 1994/12/28 20:10:25 seth Exp seth $ ';
print "\n";
exit;
}
if ($ARGV[0] eq "-h" || $ARGV[0] eq "--help")
{
&usage;
exit;
}
print STDERR "Unrecognized option: $ARGV[0]\n";
print STDERR " or bad paramater: $ARGV[1]\n" if($ARGV[1]);
&usage;
exit(1);
} continue {
shift @ARGV;
}
$preformat_trigger_lines = 0 if ($preformat_trigger_lines < 0);
$preformat_trigger_lines = 2 if ($preformat_trigger_lines > 2);
$endpreformat_trigger_lines = 1 if ($preformat_trigger_lines == 0);
$endpreformat_trigger_lines = 0 if ($endpreformat_trigger_lines < 0);
$endpreformat_trigger_lines = 2 if ($endpreformat_trigger_lines > 2);
$underline_tolerance_long = 0 if $underline_tolerance_long < 0;
$underline_tolerance_short = 0 if $underline_tolerance_short < 0;
}
sub is_blank
{
return $_[0] =~ /^\s*$/;
}
sub escape
{
$line =~ s/&/&amp;/g;
$line =~ s/>/&gt;/g;
$line =~ s/</&lt;/g;
$line =~ s/\014/\n<HR>\n/g; # Linefeeds become horizontal rules
}
sub hrule
{
if ($line =~ /^\s*([-_~=\*]\s*){$hrule_min,}$/)
{
$line = "<HR>\n";
$prev =~ s/<p>//;
$line_action |= $HRULE;
}
}
sub shortline
{
if (!($mode & $PRE) &&
!&is_blank($line) &&
($line_length < $short_line_length) &&
!&is_blank($nextline) &&
!($line_action & ($HEADER | $HRULE | $BREAK | $LIST)))
{
$line =~ s/$/<BR>/;
$line_action |= $BREAK;
}
}
sub mailstuff
{
if ((($line =~ /^\w*&gt/) || # Handle "FF> Werewolves."
($line =~ /^\w*\|/))&& # Handle "Igor| There wolves."
!&is_blank($nextline))
{
$line =~ s/$/<BR>/;
$line_action |= $BREAK | $MAILQUOTE;
} elsif (($line =~ /^[\w\-]*:/) # Handle "Some-Header: blah"
&& (($previous_action & $MAILHEADER) || &is_blank($prev))
&& !&is_blank($nextline))
{
&anchor_mail if !($previous_action & $MAILHEADER);
$line =~ s/$/<BR>/;
$line_action |= $BREAK | $MAILHEADER;
} elsif (($line =~ /^\s+\S/) && # Handle multi-line mail headers
($previous_action & $MAILHEADER) &&
!&is_blank($nextline))
{
$line =~ s/$/<BR>/;
$line_action |= $BREAK | $MAILHEADER;
}
}
sub paragraph
{
$prev .= "<p>\n";
$line_action |= $PAR;
}
sub listprefix
{
local($line) = @_;
local($prefix, $number, $rawprefix);
return (0,0,0) if (!($line =~ /^\s*[-=\*o]\s+\S/ ) &&
!($line =~ /^\s*(\d+|[a-zA-Z])[\.\)\]:]\s+\S/ ));
($number) = $line =~ /^\s*(\d+|[a-zA-Z])/;
# That slippery exception of "o" as a bullet
# (This ought to be determined more through the context of what lists
# we have in progress, but this will probably work well enough.)
if($line =~ /^\s*o\s/)
{
$number = 0;
}
if ($number)
{
($rawprefix) = $line =~ /^(\s*(\d+|[a-zA-Z]).)/;
$prefix = $rawprefix;
$prefix =~ s/(\d+|[a-zA-Z])//; # Take the number out
} else {
($rawprefix) = $line =~ /^(\s*[-=o\*].)/;
$prefix = $rawprefix;
}
($prefix, $number, $rawprefix);
}
sub startlist
{
local($prefix, $number, $rawprefix) = @_;
$listprefix[$listnum] = $prefix;
if($number)
{
# It doesn't start with 1,a,A. Let's not screw with it.
if (($number != 1) && ($number ne "a") && ($number ne "A"))
{
return;
}
$prev .= "$list_indent<OL>\n";
$list[$listnum] = $OL;
} else {
$prev .= "$list_indent<font size=-2><UL>\n";
$list[$listnum] = $UL;
}
$listnum++;
$list_indent = " " x $listnum x $indent_width;
$line_action |= $LIST;
$mode |= $LIST;
}
sub endlist # End N lists
{
local($n) = @_;
for(; $n > 0; $n--, $listnum--)
{
$list_indent = " " x ($listnum-1) x $indent_width;
if($list[$listnum-1] == $UL)
{
$prev .= "$list_indent</UL></font>\n";
} elsif($list[$listnum-1] == $OL)
{
$prev .= "$list_indent</OL>\n";
} else
{
print STDERR "Encountered list of unknown type\n";
}
}
$line_action |= $END;
$mode ^= ($LIST & $mode) if (!$listnum);
}
sub continuelist
{
$line =~ s/^\s*[-=o\*]\s*/$list_indent<LI> / if $list[$listnum-1] == $UL;
$line =~ s/^\s*(\d+|[a-zA-Z]).\s*/$list_indent<LI> / if $list[$listnum-1
] == $OL;
$line_action |= $LIST;
}
sub liststuff
{
local($i);
local($prefix, $number, $rawprefix) = &listprefix($line);
$i = $listnum;
if (!$prefix)
{
return if !&is_blank($prev); # inside a list item
# This ain't no list. We'll want to end all of them.
return if !($mode & $LIST); # This just speeds up the inevitable
$i = 0;
} else
{
# Maybe we're going back up to a previous list
$i-- while (($prefix ne $listprefix[$i-1]) && ($i >= 0));
}
if (($i >= 0) && ($i != $listnum))
{
&endlist($listnum - $i);
} elsif (!$listnum || $i != $listnum)
{
&startlist($prefix, $number, $rawprefix);
}
&continuelist($prefix, $number, $rawprefix) if ($mode & $LIST);
}
sub endpreformat
{
if(!($line =~ /\s{$preformat_whitespace_min,}\S+/) &&
($endpreformat_trigger_lines == 1 ||
!($nextline =~ /\s{$preformat_whitespace_min,}\S+/)))
{
$prev =~ s#$#\n</PRE></font>#;
$mode ^= ($PRE & $mode);
$line_action |= $END;
}
}
sub preformat
{
if($preformat_trigger_lines == 0 ||
(($line =~ /\s{$preformat_whitespace_min,}\S+/) &&
($preformat_trigger_lines == 1 ||
$nextline =~ /\s{$preformat_whitespace_min,}\S+/)))
{
$line =~ s/^/<font size=-1><PRE>\n/;
$prev =~ s/<p>//;
$mode |= $PRE;
$line_action |= $PRE;
}
}
sub make_new_anchor
{
$anchor++;
$anchor;
}
sub anchor_mail
{
local($text) = $line =~ /\S+: *(.*) *$/;
local($anchor) = &make_new_anchor($text);
$line =~ s/(.*)/<A NAME="$anchor">$1<\/A>/;
}
sub anchor_heading
{
local($heading) = @_;
local($anchor) = &make_new_anchor($heading);
$line =~ s/(<H.>.*<\/H.>)/<A NAME="$anchor">$1<\/A>/;
}
sub heading
{
local($hindent, $heading) = $line =~ /^(\s*)(.+)$/;
$hindent = 0; # This isn't used yet, but Perl warns of
# "possible typo" if I declare a var
# and never reference it.
# This is now taken care of in main()
# $heading =~ s/\s+$//; # get rid of trailing whitespace.
local($underline) = $nextline =~ /^\s*(\S+)\s*$/;
if((length($heading) > (length($underline) + $underline_tolerance_short))
|| (length($heading) < (length($underline) -$underline_tolerance_long)))
{
return;
}
# $underline =~ s/(^.).*/$1/; # Could I do this any less efficiently?
$underline = substr($underline,0,1);
local($hlevel);
$hlevel = 1 if $underline eq "*";
$hlevel = 2 if $underline eq "=";
$hlevel = 3 if $underline eq "+";
$hlevel = 4 if $underline eq "-";
$hlevel = 5 if $underline eq "~";
$hlevel = 6 if $underline eq ".";
return if !$hlevel;
$nextline = <STDIN>; # Eat the underline
&tagline("H${hlevel}");
&anchor_heading($heading);
$line_action |= $HEADER;
}
sub unhyphenate
{
local($second);
# This looks hairy because of all the quoted characters.
# All I'm doing is pulling out the word that begins the next line.
# Along with it, I pull out any punctuation that follows.
# Preceding whitespace is preserved. We don't want to screw up
# our own guessing systems that rely on indentation.
($second) = $nextline =~ /^\s*([a-zA-Z]+[\)\}\]\.,:;\'\"\>]*\s*)/; # "
$nextline =~ s/^(\s*)[a-zA-Z]+[\)\}\]\.,:;\'\"\>]*\s*/$1/; # "
# (The silly comments are for my less-than-perfect code hilighter)
$line =~ s/\-\s*$/$second/;
$line .= "\n";
}
sub untabify
{
local($oldws) = $line =~ /^([ \011]+)/;
local($oldlen) = (length($oldws));
local($i, $column);
for($i=0, $column = 0; $i < $oldlen; $i++)
{
if(substr($oldws, $i, 1) eq " ")
{ # Space
$column++;
} else { # Tab
$column += $tab_width - ($column % $tab_width);
}
}
$line = (" " x $column) . substr($line, $oldlen);
}
sub tagline
{
local($tag) = @_;
$line =~ s/^\s*(.*)\s*$/<$tag>$1<\/$tag>\n/;
}
sub caps
{
if($line =~ /^[^a-z<]*[A-Z]{$min_caps_length,}[^a-z<]*$/)
{
&tagline($caps_tag);
$line_action |= $CAPS;
}
}
sub main
{
&deal_with_options;
if(1)
{
print q(
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Description" content="ImageMagick - a robust collection of tools and libraries to read, write and manipulate an image in any of the popular image formats. ImageMagick allows dynamic creation of GIFs, making it suitable for Web applications.">
<meta name="Keywords" content="ImageMagick,Image Magick,Image Magic,PerlMagick,Perl Magick,Perl Magic,WebMagick,Web Magic,image processing,software development,simulation,image software,AniMagick,Animagic,Magick++">
<meta name="Resource-type" content="document">
<meta name="Robots" content="ALL">
<link rel="stylesheet" type="text/css" href="../www/magick.css">
</head>
<body marginheight=1 marginwidth=1 topmargin=1 leftmargin=1>
<a name="top"></a>
<table border="0" cellpadding="0" cellspacing="0" summary="Masthead" width="100%">
<tbody>
<tr>
<td bgcolor="#003399" width="25%" height="118" background="../images/background.gif"><a href="http://www.imagemagick.org/"><img src="../images/script.gif" width="278" height="118" border="0" alt="" /></a></td>
<td bgcolor="#003399" width="60%" height="118" background="../images/background.gif"><a href="http://www.networkeleven.com/direct.php?magick_all"><img src="../images/promote.png" border="0" width="186" height="52" vspace="29" alt="Powered by NetworkEleven" /></a></td>
<td bgcolor="#003399" width="114" height="118" align="right"><img src="../images/sprite.png" width="114" height="118" alt="" /></td>
<td bgcolor="#003399" width="114" height="118" align="right"><a href="http://www.imagemagick.net"><img src="../images/logo.png" width="114" height="118" border="0" alt="ImageMagick logo" /></a></td>
</tr></tbody></table>
</table><table align="left" border=0 cellpadding=2 cellspacing=2 summary="Navigation buttons" width="20%">
<tr>
<td>
<form target="_self" action="../index.html"><input type="submit" title="ImageMagick Home" value=" Home " style="background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold"></form>
</td><td>
<form target="_self" action="../www/apis.html"><input type="submit" title="ImageMagick API" value=" API " style="background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold"></form>
</td><td>
<form target="_self" action="../www/archives.html"><input type="submit" title="ImageMagick Download" value="Download" style="background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold"></form>
</td>
</tr>
</table>
<div align="right" style="margin-top:3px; padding-right:4px">
<form action="http://studio.imagemagick.org/Sage/scripts/Sage.cgi">
<input type="TEXT" name="query" size=32 maxlength=255>
<input type="SUBMIT" name="sa" value="Search" style="background-image:url('../images/background.gif'); bgcolor:#003399; color:#fbc713; font-weight:bold">
</form><br>
</div>
<table align="left" border=0 cellpadding=10 cellspacing=0 style="margin-top:-17px" width="100%"><tr><td>
<br>&nbsp;<br>
) . "\n";
print "<HTML>\n";
print "<HEAD>\n";
# It'd be nice if we could guess a title from the first header,
# but even that would be too late if we're doing this in one pass.
print "<TITLE>$title</TITLE>\n" if($title);
print "</HEAD>\n";
print q(<body text="#000000" bgcolor="#fbc713" link="#1F00FF" vlink="#9900DD" alink="#FF0000">) . "\n";
if ($title) {
print "<h3>$title</h3>\n";
}
}
$prev = "";
$line = <STDIN>;
$nextline = <STDIN>;
do
{
$line =~ s/[ \011]*$//; # Chop trailing whitespace
&untabify; # Change leading whitespace into spaces
$line_length = length($line); # Do this before tags go in
&escape;
&endpreformat if (($mode & $PRE) && ($preformat_trigger_lines != 0));
&hrule if !($mode & $PRE);
&heading if (!($mode & $PRE) &&
$nextline =~ /^\s*[=\-\*\.~\+]+$/);
&caps if !($mode & $PRE);
&liststuff if (!($mode & $PRE) &&
!&is_blank($line));
&mailstuff if ($mailmode &&
!($mode & $PRE) &&
!($line_action & $HEADER));
&preformat if (!($line_action & ($HEADER | $LIST | $MAILHEADER)) &&
!($mode & ($LIST | $PRE)) &&
($endpreformat_trigger_lines != 0));
&paragraph if ((&is_blank($prev) || ($line_action & $END)) &&
!&is_blank($line) &&
!($mode & ($LIST | $PRE)) && # paragraphs in lists
# *should* be allowed.
(!$line_action ||
($line_action & ($CAPS | $END | $MAILQUOTE))));
&shortline;
&unhyphenate if ($unhyphenation &&
($line =~ /[a-zA-Z]\-$/) && # ends in hyphen
# next line starts w/letters
($nextline =~ /^\s*[a-zA-Z]/) &&
!($mode & ($PRE | $HEADER | $MAILHEADER | $BREAK)));
# Print it out and move on.
print $prev;
if (!&is_blank($nextline))
{
$previous_action = $line_action;
$line_action = $NONE;
}
$prev = $line;
$line = $nextline;
$nextline = <STDIN>;
} until (!$nextline && !$line && !$prev);
$prev = "";
&endlist($listnum) if ($mode & $LIST); # End all lists
print $prev;
print "\n";
print "</PRE></font>\n" if ($mode & $PRE);
if ($append_file)
{
if(-r $append_file)
{
open(APPEND, $append_file);
print while <APPEND>;
} else {
print STDERR "Can't find or read file $append_file to append.\n";
}
} else {
print q(<hr>) . "\n";
print q(
<a href="#top"><img src="../images/top.gif" border=0 width="35" height="46" align="right" alt="Top of page"></a>
<form action="http://studio.imagemagick.org/magick/" style="margin-top:5px">
<input type="submit" title="Help!" value="Help!" style="background-image:url('../images/background.gif'); color:#fbc713; font-weight:bold">
<small>&quot;Image manipulation software that works like magick&quot;</small>
</form></td>
</tr></table>
) . "\n";
}
if(!$extract)
{
print "</BODY>\n";
print "</HTML>\n";
}
}
&main();

606
ImageMagick/scripts/xsnap Normal file
View file

@ -0,0 +1,606 @@
#!/bin/sh
# \
exec wish "$0" "$@"
#
# XSnap, X-Windows Snapshot. A GUI for the ImageMagick import command
#
# Software design, John Cristy (magick@dupont.com), March 1996
#
# Copyright (C) 1999-2013 ImageMagick Studio LLC, a non-profit organization
# dedicated to making software imaging solutions freely available.
#
# This software and documentation is provided "as is," and the copyright
# holders and contributing author(s) make no representations or warranties,
# express or implied, including but not limited to, warranties of
# merchantability or fitness for any particular purpose or that the use of
# the software or documentation will not infringe any third party patents,
# copyrights, trademarks or other rights.
#
# The copyright holders and contributing author(s) will not be held liable
# for any direct, indirect, special or consequential damages arising out of
# any use of the software or documentation, even if advised of the
# possibility of such damage.
#
# Permission is hereby granted to use, copy, modify, and distribute this
# source code, or portions hereof, documentation and executables, for any
# purpose, without fee, subject to the following restrictions:
#
# 1. The origin of this source code must not be misrepresented.
# 2. Altered versions must be plainly marked as such and must not be
# misrepresented as being the original source.
# 3. This Copyright notice may not be removed or altered from any source
# or altered source distribution.
#
# The copyright holders and contributing author(s) specifically permit,
# without fee, and encourage the use of this source code as a component for
# supporting image processing in commercial products. If you use this
# source code in a product, acknowledgment is not required but would be
#
#
#
# Create an alert window and display a message to the user.
#
proc Alert {dograb message args} {
#
# Initialize alert window.
#
catch {destroy .alert}
toplevel .alert -class alert
wm title .alert Alert
wm iconname .alert alert
wm group .alert .
wm transient .alert .
wm geometry .alert \
+[expr {[winfo width .]+[winfo x .]+100}]+[expr {[winfo y .]+75}]
#
# Create alert window frame.
#
frame .alert.top -relief raised -border 1
frame .alert.bottom -relief raised -border 1
pack append .alert .alert.top {top fill expand} .alert.bottom \
{top fill expand}
message .alert.top.message -width 350 -justify left -text $message
pack append .alert.top .alert.top.message {top expand padx 5 pady 5}
if {[llength $args] > 0} {
#
# Create as many buttons as needed and arrange them from left to right.
#
set arg [lindex $args 0]
frame .alert.bottom.0 -relief sunken -border 1
pack append .alert.bottom .alert.bottom.0 {left expand padx 10 pady 10}
button .alert.bottom.0.button -text [lindex $arg 0] \
-command "[lindex $arg 1]; destroy .alert"
pack append .alert.bottom.0 .alert.bottom.0.button {expand padx 12 pady 12}
bind .alert <Return> "[lindex $arg 1]; destroy .alert"
focus .alert
set i 1
foreach arg [lrange $args 1 end] {
button .alert.bottom.$i -text [lindex $arg 0] \
-command "[lindex $arg 1]; destroy .alert"
pack append .alert.bottom .alert.bottom.$i {left expand padx 20}
set i [expr $i+1]
}
}
bind .alert <Any-Enter> [list focus .alert]
if {$dograb == "grab"} {
tkwait visibility .alert
grab set .alert
} else {
focus .alert
}
}
#
# Proc AppendImageFormat appends the image format type to the filename.
#
proc AppendImageFormat {w} {
set snap(format) \
[$w.format.list get [lindex [$w.format.list curselection] 0]]
set filename [$w.file.entry get]
set extension [file extension $filename]
$w.file.entry delete \
[expr {[string length $filename]-[string length $extension]}] end
$w.file.entry insert end .
$w.file.entry insert end $snap(format)
}
#
# Proc Options creates the options window.
#
proc Options {} {
#
# Initialize snap window.
#
catch {destroy .options}
toplevel .options -class Options
wm title .options "Set Image Options"
wm group .options .
wm transient .options .
wm geometry .options \
+[expr {[winfo width .]+[winfo x .]+25}]+[winfo y .]
#
# Create options window frame.
#
frame .options.input_title
label .options.input_title.label -text "Input"
pack .options.input_title.label
pack .options.input_title
frame .options.input -relief sunken -borderwidth 2
frame .options.input.checks
checkbutton .options.input.checks.border -text "Borders" -width 11 \
-anchor w -variable snap(border)
checkbutton .options.input.checks.frame -text "Frame" -width 11 \
-anchor w -variable snap(frame)
checkbutton .options.input.checks.screen -text "Screen" -width 11 \
-anchor w -variable snap(screen)
checkbutton .options.input.checks.descend -text "Descend" -anchor w \
-variable snap(descend)
pack .options.input.checks.border .options.input.checks.frame \
.options.input.checks.screen .options.input.checks.descend -side left
pack .options.input.checks
frame .options.input.delay
label .options.input.delay.label -text "Delay:" -width 9 -anchor w
scale .options.input.delay.scale -orient horizontal -length 11c \
-from 0 -to 120 -tickinterval 15 -variable snap(delay)
pack .options.input.delay.label .options.input.delay.scale -side left
pack .options.input.delay
frame .options.input.id
label .options.input.id.window -text "Window:" -width 9 -anchor w
entry .options.input.id.window_entry -width 18 -relief sunken \
-textvariable snap(window)
label .options.input.id.display -text "Display:"
entry .options.input.id.display_entry -width 18 -relief sunken \
-textvariable snap(display)
pack .options.input.id.window .options.input.id.window_entry \
.options.input.id.display .options.input.id.display_entry -side left
pack .options.input.checks .options.input.delay .options.input.id \
-padx 1m -anchor w
pack .options.input.id -pady 1m
pack .options.input -expand 1 -fill both
frame .options.processing_title
label .options.processing_title.label -text "Image Processing"
pack .options.processing_title.label
pack .options.processing_title
frame .options.processing -relief sunken -borderwidth 2
frame .options.processing.checks
checkbutton .options.processing.checks.dither -text "Dither" -width 11 \
-anchor w -variable snap(dither)
checkbutton .options.processing.checks.negate -text "Negate" -width 11 \
-anchor w -variable snap(negate)
checkbutton .options.processing.checks.monochrome -text "Monochrome" \
-width 11 -anchor w -variable snap(monochrome)
checkbutton .options.processing.checks.trim -text "Trim" -anchor w \
-variable snap(trim)
pack .options.processing.checks.dither .options.processing.checks.negate \
.options.processing.checks.monochrome .options.processing.checks.trim \
-side left
pack .options.processing.checks
frame .options.processing.colors
label .options.processing.colors.label -text "Colors:" -width 9 -anchor w
scale .options.processing.colors.scale -orient horizontal -length 11c \
-from 0 -to 256 -tickinterval 32 -variable snap(colors)
pack .options.processing.colors.label .options.processing.colors.scale \
-side left
pack .options.processing.colors
frame .options.processing.rotate
label .options.processing.rotate.label -text "Rotate:" -width 9 -anchor w
scale .options.processing.rotate.scale -orient horizontal -length 11c \
-from 0 -to 360 -tickinterval 45 -variable snap(degrees)
pack .options.processing.rotate.label .options.processing.rotate.scale \
-side left
pack .options.processing.rotate
pack .options.processing.checks .options.processing.colors \
.options.processing.rotate -padx 1m -anchor w
pack .options.processing -expand 1 -fill both
frame .options.output_title
label .options.output_title.label -text "Output"
pack .options.output_title.label
pack .options.output_title
frame .options.output -relief sunken -borderwidth 2
frame .options.output.checks
checkbutton .options.output.checks.compress -text "Compress" -width 11 \
-anchor w -variable snap(compress)
checkbutton .options.output.checks.interlace -text "Interlace" -width 11 \
-anchor w -variable snap(interlace)
checkbutton .options.output.checks.verbose -text "Verbose" -anchor w \
-variable snap(verbose)
pack .options.output.checks.compress .options.output.checks.interlace \
.options.output.checks.verbose -side left
pack .options.output.checks
frame .options.output.scene
label .options.output.scene.label -text "Scene:" -width 9 -anchor w
scale .options.output.scene.scale -orient horizontal -length 11c \
-from 0 -to 40 -tickinterval 5 -variable snap(scene)
pack .options.output.scene.label .options.output.scene.scale -side left
pack .options.output.scene
frame .options.output.comment
label .options.output.comment.label -text "Comment:" -width 9 -anchor w
entry .options.output.comment.entry -width 45 -relief sunken \
-textvariable snap(comment)
pack .options.output.comment.label .options.output.comment.entry \
-side left
pack .options.output.comment
frame .options.output.label
label .options.output.label.label -text "Label:" -width 9 -anchor w
entry .options.output.label.entry -width 45 -relief sunken \
-textvariable snap(label)
pack .options.output.label.label .options.output.label.entry -side left
pack .options.output.label
frame .options.output.id
label .options.output.id.page -text "Page:" -width 9 -anchor w
entry .options.output.id.page_entry -width 18 -relief sunken \
-textvariable snap(page)
label .options.output.id.density -text "Density:"
entry .options.output.id.density_entry -width 18 -relief sunken \
-textvariable snap(density)
pack .options.output.id.page .options.output.id.page_entry \
.options.output.id.density .options.output.id.density_entry -side left
pack .options.output.checks .options.output.scene \
.options.output.comment .options.output.label .options.output.id \
-padx 1m -anchor w
pack .options.output.id -pady 1m
pack .options.output -expand 1 -fill both
button .options.button -text Ok -command {destroy .options}
pack .options.button
bind .options <Return> {destroy .options}
#
# Map options window.
#
pack .options.input_title .options.input .options.processing_title \
.options.processing .options.output_title .options.output .options.button \
-side top -padx 2m -pady 1m
}
#
# Proc Print prints the snapped image to a printer or command.
#
proc Print {} {
global snap
. configure -cursor watch
update
set command convert
set command [concat $command $snap(snapshot)]
set option +compress
if {$snap(compress)} {
set option "-compress zip"
}
set command [concat $command $option]
set command [concat $command -density \"$snap(density)\"]
set command [concat $command -page \"$snap(page)\"]
set command [concat $command \"ps:|$snap(printer)\"]
eval exec $command
. configure -cursor {}
}
#
# Proc PrintImage allows the user to provide a command name to print with.
#
proc PrintImage {} {
#
# Initialize print window.
#
catch {destroy .print}
toplevel .print -class Print
wm title .print Print
wm group .print .
wm transient .print .
wm geometry .print \
+[expr {[winfo width .]+[winfo x .]+75}]+[expr {[winfo y .]+50}]
#
# Create print window frame.
#
frame .print.format
scrollbar .print.format.scroll -command ".print.format.list yview"
listbox .print.format.list -yscroll ".print.format.scroll set" -setgrid 1 \
-height 8
pack .print.format.scroll -side right -fill y
pack .print.format.list -side top -expand 1 -fill both
.print.format.list insert 0 \
Letter Tabloid Ledger Legal Statement Executive A3 A4 A5 B4 B5 Folio \
Quarto 10x14
.print.format.list selection set 0
pack .print.format
frame .print.file
entry .print.file.entry -width 18 -relief sunken -textvariable snap(printer)
pack .print.file.entry -side right -expand 1 -fill both
pack .print.file
frame .print.buttons
button .print.buttons.print -text Print -command Print
button .print.buttons.cancel -text Cancel -command {destroy .print}
pack .print.buttons.print .print.buttons.cancel -side left -expand 1 \
-fill both -padx 2m
pack .print.buttons
#
# Map print window.
#
pack .print.format .print.file .print.buttons -padx 2m -pady 2m -expand 1 \
-fill both
return
}
#
# Proc Save saves the snapped image to disk.
#
proc Save {} {
global snap
if ![file readable $snap(snapshot)] {
Alert grab "You must snap an image before you can save it!" {" OK " {}}
tkwait window .alert
return
}
. configure -cursor watch
update
set command convert
set command [concat $command $snap(snapshot)]
set option +compress
if {$snap(compress)} {
set option "-compress zip"
}
set command [concat $command $option]
set command [concat $command -density \"$snap(density)\"]
set command [concat $command -page \"$snap(page)\"]
set filename $snap(filename)
if {$snap(format) != {}} {
set filename "$snap(format):$snap(filename)"
}
set command [concat $command $filename]
eval exec $command
. configure -cursor {}
}
proc SaveImage {} {
#
# Initialize save window.
#
catch {destroy .save}
toplevel .save -class Saves
wm title .save "Save As..."
wm group .save .
wm transient .save .
wm geometry .save \
+[expr {[winfo width .]+[winfo x .]+50}]+[expr {[winfo y .]+25}]
#
# Create save window frame.
#
frame .save.format
scrollbar .save.format.scroll -command ".save.format.list yview"
listbox .save.format.list -yscroll ".save.format.scroll set" -setgrid 1 \
-height 8
pack .save.format.scroll -side right -fill y
pack .save.format.list -side top -expand 1 -fill both
.save.format.list insert 0 \
ps avs bie bmp cmyk dcx eps epsf epsi fax fits gif gif87 gray g3 hdf \
histogram jbig jpeg jpg map matte miff mpg mtv pbm pcd pcx pdf pgm pict \
png ppm pnm ps2 ras rgb rle sgi sun tga tiff uyvy vid viff x xbm xpm \
xv xwd yuv yuv3
.save.format.list selection set 0
pack .save.format
frame .save.file
entry .save.file.entry -width 18 -relief sunken -textvariable snap(filename)
pack .save.file.entry -side right -expand 1 -fill both
pack .save.file
frame .save.buttons
button .save.buttons.save -text Save -command Save
button .save.buttons.cancel -text Cancel -command {destroy .save}
pack .save.buttons.save .save.buttons.cancel -side left -expand 1 \
-fill both -padx 2m
pack .save.buttons
#
# Bind buttons to print window.
#
bind .save.format.list <ButtonRelease-1> {
set snap(format) \
[.save.format.list get [lindex [.save.format.list curselection] 0]]
}
bind .save.format.list <Double-Button-1> {AppendImageFormat .save}
#
# Map save window.
#
pack .save.format .save.file .save.buttons -padx 2m -pady 2m -expand 1 \
-fill both
return
}
#
# Proc ShowImage displays the full-sized snapped image in a top level window.
#
proc ShowImage { title name } {
catch {destroy .show}
toplevel .show -visual best
wm title .show $title
button .show.image -image $name -command {destroy .show}
pack .show.image
}
#
# Proc Snap executes the ImageMagick import program to grab the image
# from the X server screen.
#
proc Snap {} {
global snap
#
# Initialize import command.
#
set command import
set command [concat $command -depth 8]
set option +border
if {$snap(border)} {
set option -border
}
set command [concat $command $option]
if {$snap(colors)} {
set command [concat $command -colors $snap(colors)]
}
set command [concat $command -comment \"$snap(comment)\"]
set option +compress
if {$snap(compress)} {
set option "-compress zip"
}
set command [concat $command $option]
if {$snap(delay)} {
set command [concat $command -delay $snap(delay)]
}
set command [concat $command -density \"$snap(density)\"]
if {$snap(descend)} {
set command [concat $command -descend]
}
set command [concat $command -display \"$snap(display)\"]
set option +dither
if {$snap(dither)} {
set option -dither
}
set command [concat $command $option]
set option +frame
if {$snap(frame)} {
set option -frame
}
set command [concat $command $option]
set option +interlace
if {$snap(interlace)} {
set option "-interlace plane"
}
set command [concat $command $option]
set command [concat $command -label \"$snap(label)\"]
set option +monochrome
if {$snap(monochrome)} {
set option -monochrome
}
set command [concat $command $option]
set option +negate
if {$snap(negate)} {
set option -negate
}
set command [concat $command $option]
set command [concat $command -page \"$snap(page)\"]
if {$snap(degrees)} {
set command [concat $command -rotate $snap(degrees)]
}
if {$snap(scene)} {
set command [concat $command -scene $snap(scene)]
}
set option +screen
if {$snap(screen)} {
set option -screen
}
set command [concat $command $option]
if {$snap(trim)} {
set command [concat $command -crop 0x0]
}
set option +verbose
if {$snap(verbose)} {
set option -verbose
}
set command [concat $command $option]
set command [concat $command $snap(snapshot)]
#
# Import the image from the X server screen.
#
. configure -cursor watch
update
wm withdraw .
eval exec $command
wm deiconify .
update
catch {image delete snapshot}
image create photo snapshot -file $snap(snapshot)
#
# Convert to an image tile.
#
exec convert -geometry 320x320> $snap(snapshot) -depth 8 $snap(tile)
catch {image delete tile}
image create photo tile -file $snap(tile)
exec rm -f $snap(tile)
#
# Display tile image as a button.
#
if [winfo exists .canvas.label] {
destroy .canvas.label
destroy .canvas.button
}
label .canvas.label -text $snap(filename)
button .canvas.button -image tile -relief sunken -borderwidth 2 \
-command { ShowImage $snap(filename) snapshot }
pack .canvas.label .canvas.button -side top -expand 1 -fill both \
-padx 1m -pady 1m
bind . <Return> { ShowImage $snap(filename) snapshot }
. configure -cursor {}
}
#
# Proc SnapWindow creates the top level window.
#
proc SnapWindow {} {
#
# Initialize snap window.
#
wm title . "X-Windows Snapshot"
wm iconname . "xsnap"
#
# Create snap window frame.
#
frame .toolbar -relief raised -bd 2
menubutton .toolbar.file -text "File" -menu .toolbar.file.menu -underline 0
menu .toolbar.file.menu
.toolbar.file.menu add command -label "Save" -command Save
.toolbar.file.menu add command -label "Save As ..." -command "SaveImage"
.toolbar.file.menu add command -label Print -command PrintImage
.toolbar.file.menu add separator
.toolbar.file.menu add command -label Quit \
-command { exec rm -f $snap(snapshot); exit }
pack .toolbar.file -side left
pack .toolbar -side top -fill x
canvas .canvas -width 256 -height 128
pack .canvas
frame .buttons
button .buttons.snap -text Snap -command Snap
button .buttons.options -text Options -command Options
pack .buttons.snap .buttons.options -side left -expand 1
pack .buttons -side bottom -fill x -padx 2m -pady 2m
#
# Map snap window.
#
pack .toolbar .canvas .buttons
}
#
# Initalize snap options.
#
set snap(border) 0
set snap(colors) 0
set snap(comment) "Imported from %m image: %f"
set snap(compress) 1
set snap(degrees) 0
set snap(delay) 0
set snap(density) 72x72
set snap(descend) 0
set snap(display) :0
if [info exists env(DISPLAY)] {
set snap(display) $env(DISPLAY)
}
set snap(dither) 1
set snap(filename) magick.ps
set snap(format) {}
set snap(frame) 0
set snap(interlace) 1
set snap(label) "%f %wx%h"
set snap(monochrome) 0
set snap(negate) 0
set snap(page) Letter
set snap(printer) lp
set snap(scene) 0
set snap(screen) 0
set snap(snapshot) /tmp/snap[pid].ppm
set snap(tile) /tmp/tile[pid].ppm
set snap(trim) 0
set snap(verbose) 0
#
# Create top level snap window.
#
SnapWindow
tkwait window .
exec rm -f $snap(snapshot)