Mailinglist Archive: opensuse (924 mails)

< Previous Next >
Re: [opensuse] bash script to build html gallery
  • From: Per Jessen <per@xxxxxxxxxxxx>
  • Date: Fri, 05 Oct 2012 08:13:45 +0200
  • Message-id: <k4ltqq$omc$1@saturn.local.net>
Eric Gunther wrote:

[snip]
Thanks for any help,


Eric, it's a fairly simple programming problem you got here, whether
you do it in bash, simula2 or lisp. There are plenty of people here
who can whip up a script for you in no time, but is that what you
really want? It might better with soe more specific questions.

I appreciate that, and also I appreciate the frank response. But in
reality I actually just want to get to the html page, then the upload
and convert script, and then move on to better things.

Here is something to work on:

----------
#!/bin/sh
dir=<yourphotodir>
perpage=8
page=0
find $dir -type f |\
while read image
do
page=$(expr $page + 1)
printf "<html><head><title>%s page %u</title></head><body>" $dir $page

n=$perpage
while test $n -gt 0
do
thumb="thumbnails/"$(basename $image)
convert $image -scale 256x192 $thumb
printf "\n<a href=\"%s\"><img src=\"%s\"/></a>" $image $thumb
n=$(expr $n - 1)
test $n -gt 0 && read image
done

printf "</body></html>\n"

done
---------

It's not perfect, plenty of room for optimization. You'll need to
manually separate the pages and write some CSS for the formatting.



--
Per Jessen, Zürich (11.8°C)

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups