#!/bin/sh # vim: set sw=4 ts=4 et: # wirtten by katja socher # # ver="0.3" help() { cat < 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 (there might be a space in the file name) imgfile="$1" shift while [ -n "$imgfile" ]; do if [ ! -r "$imgfile" -o -d "$imgfile" ]; then echo "ERROR: can not read file $imgfile" else geometry=`identify "$imgfile" | sed -e 's/^.* \([0-9][0-9]*x\)/\1/' | awk '{print $1}'` # 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 "\"[]\"" fi if [ -z "$1" ]; then exit 0 fi imgfile="$1" shift done exit 0