#!/bin/bash
#                       /usr/local/bin/imgs
# https://crystalfaeries.net/posix/bin/imgs
# celeste:crystalfaery IMGS 2016-08-28 01:23:08+00:00
# generate HTML img reference lines for each .jpg and .png in cwd
if [ $# -eq 0 ]
then	# no arguments defaults to all files in cwd
    for f in $(ls *.{jpg,png})
    do
	echo "<img      alt=\"[$(basename $f)]\", src=\"`pwd|sed 's/\/home\/www//'`/$f\", $(file $f|sed 's/, frames [0-9]$//g;s/, 8-bit.*$//g;s/^.*, //g;s/x/ x /g;s/  / /g;s/^/width="/g;s/ x /", height="/g;s/$/"/g')>"
    done
else	# or iterate specified filenames
    while [ $# -ne 0 ]
    do
	f="${1}";shift
	echo "<img      alt=\"[$(basename $f)]\", src=\"`pwd|sed 's/\/home\/www//'`/$f\", $(file $f|sed 's/, frames [0-9]$//g;s/, 8-bit.*$//g;s/^.*, //g;s/x/ x /g;s/  / /g;s/^/width="/g;s/ x /", height="/g;s/$/"/g')>"
    done
fi


syntax highlighted by Code2HTML, v. 0.9.1