From 81b99caf1cda3875dbca14c7af71ddefe68c9985 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 30 Jul 2001 04:51:43 +0000 Subject: [PATCH] Ready to ship. --- Makefile | 4 ++-- imgsizer | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index cce463d..944ffc5 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ # Makefile for the imgsizer distribution -VERS=2.0 +VERS=2.1 # These choices are correct for Linux. Season to taste. BINDIR = /usr/bin -MANDIR = /usr/man/man1 +MANDIR = /usr/share/man/man1 install: cp imgsizer $(BINDIR) diff --git a/imgsizer b/imgsizer index 8b22a35..f94d109 100755 --- a/imgsizer +++ b/imgsizer @@ -5,8 +5,7 @@ # # Fix up IMG tags in given documents to contain correct sizes. No longer # requires the identify(1) program from the ImageMagick suite if you have -# a decent file(1) and rdjpgcom(1). To fix up sizes for non-local images -# it requires the httpget(1) script. +# a decent file(1) and rdjpgcom(1). # # Works with Python 1.5.2 # @@ -54,9 +53,9 @@ # try commands in least to most expensive order, and notice when a command # returns not to try it again. # -import sys, os, getopt, filecmp, string, re, urllib, commands +import sys, os, getopt, cmp, string, re, urllib, commands -version = "2.0, 11 July 2001"; +version = "2.1, 26 July 2001"; splash = """imgsizer version %s, Eric S. Raymond See for updates.""" @@ -80,7 +79,7 @@ Options: -n, --no-overwrite - Don't overwrite existing width and heigbt tags if both are present. + Don't overwrite existing width and height tags if both are present. """ @@ -106,7 +105,7 @@ def sizefix(infp, outfp): if ch == '': return outfp.write(lead) - if lead.find('>') > -1: + if string.find(lead, '>') > -1: continue if not lead in ("img", "IMG"): continue @@ -150,7 +149,7 @@ def imgsize(src): return (sizes.group(1), sizes.group(2)) elif status == 127: rdjpgcom = 0 - # Next try identify(1), more expensive nut bulletproof + # Next try identify(1), more expensive but bulletproof if magick: (status, output) = commands.getstatusoutput("identify " + filename) if status == 0: @@ -158,9 +157,10 @@ def imgsize(src): if sizes: return (sizes.group(1), sizes.group(2)) elif status == 127: + sys.stderr.write("imgsizer: giving up on ImageMagick\n") magick = 0 # All attempts failed - sys.stderr.write("imgsizer: couldn't analyze " + src) + sys.stderr.write("imgsizer: couldn't analyze %s\n" % src) source = re.compile('SRC="?([^" \t\n]*)"?', re.I) awidth = re.compile(' *WIDTH="?[0-9]*"?', re.I) @@ -201,7 +201,7 @@ quotes = 1 root = "." out = "imgsizer-out$$" -dir = "." # NOTE: if you are doing