From e759375abbd4f967381490b8e6812aa4899deeeb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 26 Mar 1997 15:14:25 +0000 Subject: [PATCH] Ready to release. --- Makefile | 4 +++- README | 6 ++++-- imgsizer | 28 +++++++++++++++++++++++----- imgsizer.xml | 11 +++++++---- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 8c35791..054ce95 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ install: cp imgsizer httpget $(BINDIR) cp imgsizer.man $(MANDIR)/imgsizer.1 -DISTDIR = imgsizer-1.1 +DISTDIR = imgsizer-1.2 FILES = $(DISTDIR)/Makefile $(DISTDIR)/READ.ME $(DISTDIR)/httpget \ $(DISTDIR)/imgsizer $(DISTDIR)/imgsizer.lsm \ $(DISTDIR)/imgsizer.man @@ -17,3 +17,5 @@ $(DISTDIR).tar: $(DISTDIR).tar.gz: $(DISTDIR).tar gzip -f $(DISTDIR).tar +dist: $(DISTDIR).tar.gz + ls -l $(DISTDIR).tar.gz diff --git a/README b/README index 10980e5..2b1c42d 100644 --- a/README +++ b/README @@ -1,7 +1,8 @@ - imgsizer -- autogenerate WIDTH and HEIGHT for IMG tags + imgsizer -- autogenerate WIDTH and HEIGHT for IMG tags This is a nifty little HTML authoring tool that will generate correct Netscape-style WIDTH and HEIGHT parameters for each of your IMG tags. +This will enable the text parts of your page to load much faster. Files in this directory: @@ -20,10 +21,11 @@ work. If you are using Linux or any of the free BSDs it is probably already on your system; otherwise, you should be able to get it from ftp://ftp.x.org/contrib/applications/ImageMagick. -Usual terms -- copy, use, and redistribute as you like, don't take +Usual FRS terms -- copy, use, and redistribute as you like, don't take my name off it, and clearly mark any modified versions. Fixes and enhancements cheerfully accepted. Enjoy! -- esr + http://www.ccil.org/~esr diff --git a/imgsizer b/imgsizer index a53bba8..fea451d 100755 --- a/imgsizer +++ b/imgsizer @@ -13,13 +13,18 @@ # clearly mark an altered version. Fixes and enhancements cheerfully # accepted. # -# This is version 1.1. +# This is version 1.2. # +# Anything that can fetch a URL defined on the command line +# and dump it to stdout will do here. +$fetcher = 'httpget'; + $out = "imgsizer-out$$"; if (@ARGV) { foreach $x (@ARGV) { $file = $x; + $dir = &dirname($x); open(TEMP, ">$out") || die("imgsizer: couldn't open tempfile $out \n"); close(STDIN); @@ -29,7 +34,7 @@ if (@ARGV) { select(TEMP); &sizefix; close(TEMP); - if (!rename($out, $file)) { + if (system("cp $out $file")) { print STDERR "imgsize: couldn't replace ${file}\n}"; } } @@ -41,6 +46,18 @@ else { &sizefix; } +sub dirname +# return filename with the basename part stripped away +{ + my($file) = @_; + if ($file =~ /\//) { + $file =~ s:/[^/]*$::; + } else { + $file = "."; + } + return($file); +} + sub getchar { $pushback = if (length($pushback) == 0); @@ -89,15 +106,16 @@ sub attrfix if ($url =~ /^http:/) { $image = "imgsizer-tmp$$"; - $status = system("httpget ${url} >${image}"); + $status = system("$fetcher ${url} >${image}"); if ($status) { &error("can't fetch $1"); unlink("imgsizer-tmp$$"); return $attribs; } } - else { - $image = $url; # This catches local files + elsif (!($url =~ /^[a-z]+:/)) { + $image = "$dir/$url"; # This catches local files + } ($name, $size) = split(' ', `identify ${image}`); diff --git a/imgsizer.xml b/imgsizer.xml index 0d1342e..3ab9331 100644 --- a/imgsizer.xml +++ b/imgsizer.xml @@ -13,7 +13,7 @@ extension HEIGHT and WIDTH parameters in HTML IMG tags. These parameters help many browsers (including Netscape) to multi-thread image loading, instead of having to load images in strict sequence in order to have each one's dimensions available so the next can be -placed. This generally alllows text on the remainder of the page +placed. This generally allows text on the remainder of the page to load much faster. .PP This script may be called with no arguments. In this mode, it filters @@ -34,7 +34,7 @@ utility is used to extract sizes from the images; itself has no knowledge of graphics formats. The script will handle any image format known to .IR identify (1) -including GIF, JPEG, XBM, XPM, PostScript, BMP, TIFF, and anything else +including PNG, GIF, JPEG, XBM, XPM, PostScript, BMP, TIFF, and anything else even remotely likely to show up as an inline image. .PP In order for @@ -43,11 +43,14 @@ to correctly interpret remote URLs, the freeware script .IR httpget (1) must be executable and present in your execution path; .B imgsizer -will complain and fail if +will complain and fail if either +.IR identify (1) +or .IR httpget (1) is needed and not present. .SH AUTHOR -Eric S. Raymond . +Eric S. Raymond . See my home page at +http://www.ccil.org/~esr for updates. .SH SEE ALSO .IR identify (1), .IR httpget (1). -- 2.43.0