";
curpicts = curpicts+1;
if (img2caption != "") {
tmpcaption = img2caption;
}
else if (defcap != "") {
tmpcaption = defcap;
}
else {
tmpcaption = img2;
}
if (title == tmpcaption) {
titlestr = title " - " img2;
}
else {
titlestr = title " - " tmpcaption;
}
if (footer!="") {
altstr = titlestr " - " footer;
}
else {
altstr = titlestr;
}
altstrthumb = tmpcaption;
gsub("\"","",altstr);
gsub("\"","",altstrthumb);
img2html = destdir "/" img2 key "_.html";
system ("rm -f " img2html);
getwh = "identify -format '%wx%h' " destdir "/thumbs/" img2 "_thumb.jpg";
getwh | getline wxh;
close(getwh);
split(wxh,wh,"x");
printf "";
printf "";
printf " ";
if (idxname) {
printf " " img2 "";
}
printf " | \n";
if (idxlnkanc) {
idxlnk = "#" img2;
}
else {
idxlnk = "";
}
print "\n\
\n\
\n\
\n\
" gensub("<[^>]*>","","g",titlestr) "\n\
\n\
\n\
\n\
" > img2html;
printf "\n" > img2html;
if (img1 == "") {
printf " | \n" > img2html;
}
else {
printf " | \n" > img2html;
}
printf " | \n" > img2html;
if (img3 == "") {
printf " | \n" > img2html;
}
else {
printf " | \n" > img2html;
}
printf "
\n" > img2html;
print "" tmpcaption "
" > img2html;
getwh = "identify -format '%wx%h' " destdir "/" img2;
getwh | getline wxh;
close(getwh);
split(wxh,wh,"x");
printf "\n" > img2html;
if (usemap) {
wt = int(wh[1]/3);
hm = int(wh[2]*usemap);
if (hm < 1) hm = 1;
if (hm > wh[2]) hm = wh[2];
printf "\n" > img2html;
}
if (footer!="") {
print "" footer "
" > img2html;
}
print "\n\
\n\
" > img2html;
close(img2html);
}
BEGIN {
if (ARGC==1) {
print "usage: \\ls *.jpg | makehtmlgallery7 >! index.html" > "/dev/stderr";
print "or: makehtmlgallery7 title=\"TITLE\" < imglist >! index.html" > "/dev/stderr";
print "or: makehtmlgallery7 key=_xxx title=\"TITLE\" < imglist >! index_xxx.html" > "/dev/stderr";
print "or: makehtmlgallery7 key=_xxx srcdir=\"???canon\" destdir=size-800 \\" > "/dev/stderr";
print " imgsize='\"800x800>\"' forceconvert=1 usemap=1 idxlnkanc=1\\" > "/dev/stderr";
print " thumbcols=6 thumbsize=100x100 idxname=1 \\" > "/dev/stderr";
print " title=\"All My Images\" idxcap=\"[back]\" \\" > "/dev/stderr";
print " defcap=\"My Image\" footer=\"Photo: A. Nonymus 2006\" \\" > "/dev/stderr";
print " backlink=\"../index.html\" \\" > "/dev/stderr";
print " < imglist >! size-800/index_xxx.html" > "/dev/stderr";
print " imglist is a text file with a single image file name per line," > "/dev/stderr";
print " optionally followed by a rotation angle (deg cw) and/or comment/caption." > "/dev/stderr";
print " If imgsize is specified, images in srcdir are scaled & rotated to destdir." > "/dev/stderr";
print " title specifies the title of the index HTML page (default \"Image Galery\")." > "/dev/stderr";
print " idxname=1 adds filenames to thumbnails on index page." > "/dev/stderr";
print " defcap is default (instead of filename) if no caption in imglist." > "/dev/stderr";
print " footer is appened below all photo HTML pages." > "/dev/stderr";
print " backlink is added to index HTML page." > "/dev/stderr";
print "" > "/dev/stderr";
}
thumbcols = 6;
thumbsize = "100x100";
srcdir = ".";
destdir = ".";
imgsize = "";
forceconvert = 0;
usemap = 0;
idxlnkanc = 0;
title = "Image Gallery";
# srcdir = "???canon";
# destdir = "size-800";
# imgsize = "800x800";
imgsize = "1920x1080";
idxcap = "";
idxname = 0;
defcap = "";
footer = "";
backlink = "";
img1 = "";
img2 = "";
img3 = "";
img2caption = "";
img3caption = "";
curpicts = 0;
curcols = 0;
}
{
if (NR==1) {
split(thumbsize,twh,"x");
if (idxname) {
tdstring = "width=\"" twh[1]+20 "\" height=\"" twh[2]+35 "\"";
}
else {
tdstring = "width=\"" twh[1]+20 "\" height=\"" twh[2]+20 "\"";
}
if (system("test -e " destdir "/thumbs")) {
print "making directory thumbs" > "/dev/stderr";
system ("mkdir -p " destdir "/thumbs");
}
system ("( cd " destdir " ; echo 'H4sIAIJ94kYCA+3XP0gCURzA8af0R2wooqXtgqDIlPfuz3tJU0t1RHtOcYOekoadZ+jQpiEubQ7S 0pZDYENTDQ0JQXR7RDo0SENbILbUnVJbhMOJV7/Pcrx3t37f7108HNEFPkOoElBjEWQLbKKiaD0J ljpPTLrrDsJTRDBlWGSEFyjCRMCMIg6jPkindEXjOJRMa7tRRQ3//F1YS6E/Z01eXQoqHJpAJy5r /fFlpj3k8pobi9au9R6553JHlbvX8ZXCWy70XHtI1P2NTH5ELk++V3xjh2e+kn4g7BmtYbSMgEOk k3bX31v/giSZ/fMS46H/Qe3fc14O+m+2mJH1eoqjclk+DcQv95PH97c7G5rRhP4dRIupUbsvAL/3 z777N9O35r95AED/g9b/fLf/zcJUPvRSayfqcsOzPztdbJbcvseF7atrXXu6MFrrLjgAHCNu3v9V TcnaeQT0MP95Sjv9M4ah/z7377bW1WoV7v//bf7bfAD0MP95hq3/f5FI0P/A9Q/zHwAAAAAAAAAA AAAAAJzjEzHzWXwAKAAA' | perl -MMIME::Base64 -ne 'print decode_base64($_)' | gunzip -c | tar x )");
print "\n\
\n\
\n\
\n\
" gensub("<[^>]*>","","g",title) "\n\
\n\
\n\
\n\
\n\
" title "
";
if (backlink!="") {
print "[back]
";
}
if (idxcap!="") {
print "" idxcap "
";
}
print "";
}
if (imgsize != "") {
cntsrc = "ls " srcdir "/" $1 " | wc";
cntsrc | getline numsrc;
close(cntsrc);
split(numsrc,numsrcar);
if (numsrcar[1]==0) {
print "ERROR: missing source file " srcdir "/" $1 > "/dev/stderr";
exit;
}
if (numsrcar[1]>1) {
print "ERROR: ambiguous source file " srcdir "/" $1 > "/dev/stderr";
exit;
}
rot = 0+$2;
if (forceconvert ||
!system("test " srcdir "/" $1 " -nt " destdir "/" $1)) {
print "generating " destdir "/" $1 > "/dev/stderr";
# system ("convert " srcdir "/" $1 " -resize " imgsize " -rotate " rot " -unsharp 1x1+0.5+0 -quality 93 -sampling-factor 1x1 " destdir "/_makehtmlgallery_tmp_" $1);
system ("convert " srcdir "/" $1 " -rotate " rot " -resize " imgsize " -unsharp 1x1+0.5+0 -background black -gravity center -extent " imgsize " -quality 97 -sampling-factor 1x1 " destdir "/_makehtmlgallery_tmp_" $1);
system ("rm -f " destdir "/" $1);
system ("exiftool -n -Orientation=1 -m -thumbnailimage= -previewimage= -o " destdir "/" $1 " " destdir "/_makehtmlgallery_tmp_" $1 " > /dev/stderr");
system ("rm -f " destdir "/_makehtmlgallery_tmp_" $1);
}
}
if (forceconvert ||
system("test -e " destdir "/thumbs/" $1 "_thumb.jpg") ||
!system("test " destdir "/" $1 " -nt " destdir "/thumbs/" $1 "_thumb.jpg")) {
print "converting " destdir "/" $1 " to " destdir "/thumbs/" $1 "_thumb.jpg" > "/dev/stderr";
system ("convert " destdir "/" $1 " +profile \"*\" -resize " thumbsize " -unsharp 1x1+0.5+0 -quality 93 -sampling-factor 1x1 " destdir "/thumbs/" $1 "_thumb.jpg");
}
if (!system("test -e " destdir "/thumbs/" $1 "_thumb.jpg")) {
print "adding " $1 " (thumbs/" $1 "_thumb.jpg) to gallery" > "/dev/stderr";
img1 = img2;
img2 = img3;
img2caption = img3caption;
img3 = $1;
captionstart = length($1)+2;
if (match($2,"[0-9+\\-]")) {
captionstart += length($2)+1;
}
img3caption = substr($0,captionstart);
if (img2 != "") {
makepict(img1, img2, img3, img2caption, title);
}
}
}
END {
if (img3 != "") {
makepict(img2, img3, "", img3caption, title);
for (;curpicts ";
print ""
}
print "
";
print "
\n\
generated by \
\
makehtmlgallery7hd (v20120419) on";
system ("date \"+%a %F %T\"");
print "
\n\
\n\
\n\
";
}
#--