#!/bin/csh -f # # mkgallery v2006-05-16 pinkwerks # # Usage: # mkgallery [depth | clean] # # Notes: # # creates a web photo thumbnail gallery with frames from images in the # current directory and anybelow. it deals only with jpegs for now. # does movies sort of.. (have to look into it again) # doesn't do well with spaces. # # Requires : ImageMagik set GAL = gallery set findcmd = "find" if ( ${#argv} == 1 ) then if ($1 == "clean") then rm -rf ${GAL} exit 0 else set maxdepth = `echo $1 | bc` set findcmd = "find -maxdepth ${maxdepth}" if ( ${maxdepth} < 1 ) set findcmd = "find" endif else if ( ${#argv} > 1 ) then echo Bad number of args! exit 1 endif # CONFIG set CACHED = 'c' set GEN = '+' set HTMLHEAD = '<\!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' set HICLASS = 'bigimage' set HI_X = 640 set HI_Y = 480 set HI_SIZE = "${HI_X}x${HI_Y}" set HI_QUALITY = 85 set HI_DIR = hi set LO_X = 64 set LO_Y = 48 @ LO_Y2 = ${LO_Y} + ${LO_Y} set LO_SIZE = "${LO_X}x${LO_Y}" set LO_QUALITY = 100 set LO_DIR = lo set PAGES = ${GAL}/pages set index = ${GAL}/index.html set mainFrame = ${GAL}/mainframe.html set mF = mainframe.html set thumbFrame = ${GAL}/thumbframe.html set tF = thumbframe.html set homeurl = http://pinkwerks.com # make sure we have some dirs to work with if ( ! -ewd $GAL ) then mkdir $GAL chmod 775 $GAL endif if ( ! -e ${GAL}/${LO_DIR} ) mkdir -p ${GAL}/${LO_DIR} if ( ! -e ${GAL}/${HI_DIR} ) mkdir ${GAL}/${HI_DIR} if ( ! -e ${PAGES} ) mkdir ${PAGES} # CSS MESS set cssfile = "${cwd:t}.css" set css = ${cssfile} set css2 = "../${cssfile}" set css = '' set css2 = '' cat > gallery/${cssfile} << EOF BODY { font : bold 8pt sans-serif; color : black; background-color : rgb(50%,50%,50%); } .home {text-align:center;} H1 {text-align:center;} IMG { border:0px; } .thumbnail { vertical-align:center; } .imgtitle { text-align:center; color:rgb(45%,45%,45%); } .bigimage { text-align:center; } EOF # Build the index : NOTE the use of '>' instead of '>>' !!! echo ${HTMLHEAD} > ${index} echo "
| ' >> ${thumbFrame} #echo -n 'Home' >> ${thumbFrame} echo ' | ' >> ${thumbFrame} # movies if ( -e movies ) then cd movies foreach m ( *.mpg *.MPG ) transcode -z -i "$m" -o /tmp/$m -y im,null -F jpg set NUM = `ls -1 /tmp/$m* | wc -l` set NUM = `echo "$NUM / 2" | bc` set ICON = `ls -1 /tmp/$m*${NUM}*.jpg` convert -geometry "${LO_SIZE}" ${ICON} ../${GAL}/${LO_DIR}/${m}.jpg rm /tmp/dummy*.jpg echo -n '' >> ../${thumbFrame} echo end cd .. endif # # IMAGES # set jpgs = `${findcmd} -iname \*.jpg -not -path './gallery/*'` foreach jpgWithPath ( ${jpgs} ) file "${jpgWithPath}" | grep -i image > & /dev/null set jpgNoPath = ${jpgWithPath:t} if ( $status == 0 ) then # { if ( -e ${GAL}/${HI_DIR}/hi_${jpgNoPath} == 0 ) then echo "${GEN} ${jpgWithPath} -> ${GAL}/${HI_DIR}/hi_${jpgNoPath}" convert -quality ${HI_QUALITY} -geometry "${HI_SIZE}" \ ${jpgWithPath} ${GAL}/${HI_DIR}/hi_${jpgNoPath} else echo "${CACHED} ${GAL}/${HI_DIR}/hi_${jpgNoPath}" endif # Figure out the current images resolution for purposes # of clearly identifing it's size to the html browser # of course. set tmp = `identify ${GAL}/${HI_DIR}/hi_${jpgNoPath} | cut -d' ' -f3` set X = `echo $tmp | cut -dx -f1` set Y = `echo $tmp | cut -dx -f2` # # Build big picture page # echo ${HTMLHEAD} > ${PAGES}/${jpgNoPath}.html echo "" >> ${PAGES}/${jpgNoPath}.html echo ${css2} >> ${PAGES}/${jpgNoPath}.html echo '' >> ${PAGES}/${jpgNoPath}.html echo '' >> ${PAGES}/${jpgNoPath}.html echo ' | ' >> ${thumbFrame}
echo -n ' ' >> ${thumbFrame}
echo -n '' >> ${thumbFrame}
echo -n ' ' >> ${thumbFrame}
echo ' | ' >> ${thumbFrame}
# }
else
echo "X ${jpgWithPath}"
endif
end
echo -n '' >> ${thumbFrame} #echo -n "Home" >> ${thumbFrame} echo " | " >> ${thumbFrame} echo '