#!/bin/sh # # A shell script to get image sizes, and return a well-formed html IMG # tag. It requires basename, awk and the identify program from the # ImageMagick suite. # # Author: R.F. Smith # Time-stamp: <2010-08-29 14:06:37 rsmith> # # To the extent possible under law, Roland Smith has waived all copyright and # related or neighboring rights to imgsize. This work is published from the # Netherlands. See http://creativecommons.org/publicdomain/zero/1.0/ # Check for arguments if [ $# -eq 0 ]; then echo "Usage: $(basename $0) filename [\"alt text\"]" exit 1 fi if [ ! -f $1 ]; then echo $ID echo 'The file "'$1'" does not exist in this directory.' exit 1 fi # Check for special programs that are used in this script. PROGS="identify" for P in $PROGS; do which $P >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "$(basename $0): The program \"$P\" cannot be found." exit 1 fi done echo -n '/dev/null |awk '{print($3);}'|\ awk -F "x" '{printf("width=%d height=%d />\n",$1,$2);}'