#!/bin/sh # vim: set sw=4 ts=4 et: # wirtten by katja socher <katja@linuxfocus.org> # and guido socher <guido@linuxfocus.org> # # ver="0.1" help() { cat <<HELP imgsrcline -- generate a <img src=... width= height=> line for a number of images USAGE: imgsrcline [-h] image1 image2 ... OPTIONS: -h this help EXAMPLE: imgsrcline test.gif This program uses the identify utility from ImageMagick version $ver HELP exit 0 } error() { echo "$1" exit "$2" } while [ -n "$1" ]; do case $1 in -h) help;shift 1;; --) break;; -*) echo "error: no such option $1. -h for help";exit 1;; *) break;; esac done if [ -z "$1" ];then error "No image specified, -h for help" 1 fi # process each image for imgfile in $* ;do if [ ! -r "$imgfile" ]; then echo "ERROR: can not read $imgfile\n" else geometry=`identify $imgfile | awk '{print $2}'` # geometry can be 563x144+0+0 or 75x98 # get rid of the +0+0 width=`echo $geometry | sed 's/[^0-9]/ /g' | awk '{print $1}'` height=`echo $geometry | sed 's/[^0-9]/ /g' | awk '{print $2}'` echo "<img src=\"$imgfile\" width=\"$width\" height=\"$height\" alt=\"[]\">" fi donemirror server hosted at Truenetwork, Russian Federation.