[opensuse] bash script to build html gallery
Hello list, I want to make a script which builds static html pages from a directory of images. 8 images per page. Using tables. I was thinking that making the import and convert part, in a separate script, using gphoto2 and Image Magick respectively. The current script works with a template that is only the table row (<tr> </tr>) definition. *script* for one in *.JPG; do sed s/image/$one/g gallery.tmplt >> gallery.html done *template* <tr> <a href="image"> <img src="small_image" alt="image"/></a> </tr> What this yields is a page full of the name of the image as a link to the large image. I assume this behavior with the "alt" field being shown is because there is an underscore in the "img src" field. So I would like to correct a few things: + have the template transcription stop at 8 images, to start a new page. + have the sed command able to interpret a template with multiple image locations, so that I can have an entire web-page as a template and not just the table row section (see below for clarification). + have the underscore behavior changed--- although I had this working so this problem is minor. :clarification: The idea of the loop occurred to me because I have a list of images "----for one in *.JPG; do--------" from which I want to pluck images. "--------sed s/image/$one/ gallery.tmplt >> gallery.html---" So that when the script encounters the word (regex) it then replaces it with the next in the list. Where I have the difficulty is when I have multiple "image" instances in the page. I think I may be able to get the desired behavior with another loop, which increments "n", something like this; ------n=0 ------n=n+1 ------sed /n/s/image/$one/ gallery.tmplt >> gallery.html Because I would like to replace all occurrences on a line with the current image. This would be useful for me to understand because I think I could implement the same simple technique to count the images per page. Thanks for any help, -e -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Eric Gunther wrote:
<tr> <a href="image"> <img src="small_image" alt="image"/></a> </tr>
What this yields is a page full of the name of the image as a link to the large image. I assume this behavior with the "alt" field being shown is because there is an underscore in the "img src" field.
The contents of the "alt" attribute is shown when the image cannot be found. [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. -- Per Jessen, Zürich (16.4°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Thu, 2012-10-04 at 18:26 +0200, Per Jessen wrote:
Eric Gunther wrote:
<tr> <a href="image"> <img src="small_image" alt="image"/></a> </tr>
What this yields is a page full of the name of the image as a link to the large image. I assume this behavior with the "alt" field being shown is because there is an underscore in the "img src" field.
The contents of the "alt" attribute is shown when the image cannot be found.
Yes, and the reason the image is not found is because the path is wrong... the reason the path is wrong is because "small_image" was not replaced.
[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. You see, I take nice pictures and I am sort of artistically inclined so I: 1.) Have trouble parsing the man pages and associated information. I have, in fact, spent hours trying to get this idea to work, with sed, and have gotten starts and stops but no success. 2.) Would like a simple stable script with which to display them, preferably one which I have written so that I can fix it or change it as the demand changes. I have seen other things in the man pages about prompting and things of an interactive nature that I may put in later in sooner but that is not what I am working on. I feel somewhat exposed but, that's more or less it, thanks, -e
-- Per Jessen, Zürich (16.4°C)
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
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@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Thank You kindly, -e On Fri, 2012-10-05 at 08:13 +0200, Per Jessen wrote:
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@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/04/12 12:13, Eric Gunther pecked at the keyboard and wrote:
Hello list,
I want to make a script which builds static html pages from a directory of images.
8 images per page. Using tables. I was thinking that making the import and convert part, in a separate script, using gphoto2 and Image Magick respectively.
The current script works with a template that is only the table row (<tr> </tr>) definition.
*script*
for one in *.JPG; do
sed s/image/$one/g gallery.tmplt >> gallery.html
done
*template*
<tr>
<a href="image"> <img src="small_image" alt="image"/></a>
</tr>
What this yields is a page full of the name of the image as a link to the large image. I assume this behavior with the "alt" field being shown is because there is an underscore in the "img src" field.
So I would like to correct a few things:
+ have the template transcription stop at 8 images, to start a new page.
+ have the sed command able to interpret a template with multiple image locations, so that I can have an entire web-page as a template and not just the table row section (see below for clarification).
+ have the underscore behavior changed--- although I had this working so this problem is minor.
:clarification:
The idea of the loop occurred to me because I have a list of images
"----for one in *.JPG; do--------"
from which I want to pluck images.
"--------sed s/image/$one/ gallery.tmplt >> gallery.html---"
So that when the script encounters the word (regex) it then replaces it with the next in the list. Where I have the difficulty is when I have multiple "image" instances in the page. I think I may be able to get the desired behavior with another loop, which increments "n", something like this;
------n=0 ------n=n+1 ------sed /n/s/image/$one/ gallery.tmplt >> gallery.html
Because I would like to replace all occurrences on a line with the current image. This would be useful for me to understand because I think I could implement the same simple technique to count the images per page.
Thanks for any help,
-e
Take a look at JAlbum, it may fulfill your needs without having to re-invent the wheel. http://jalbum.net/en/software/download -- Ken Schneider SuSe since Version 5.2, June 1998 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
on Thu, 2012-10-04 at 13:02 -0400, Ken Schneider - openSUSE wrote:
On 10/04/12 12:13, Eric Gunther pecked at the keyboard and wrote:
Hello list,
I want to make a script which builds static html pages from a directory of images.
8 images per page. Using tables. I was thinking that making the import and convert part, in a separate script, using gphoto2 and Image Magick respectively.
The current script works with a template that is only the table row (<tr> </tr>) definition.
*script*
for one in *.JPG; do
sed s/image/$one/g gallery.tmplt >> gallery.html
done
*template*
<tr>
<a href="image"> <img src="small_image" alt="image"/></a>
</tr>
What this yields is a page full of the name of the image as a link to the large image. I assume this behavior with the "alt" field being shown is because there is an underscore in the "img src" field.
So I would like to correct a few things:
+ have the template transcription stop at 8 images, to start a new page.
+ have the sed command able to interpret a template with multiple image locations, so that I can have an entire web-page as a template and not just the table row section (see below for clarification).
+ have the underscore behavior changed--- although I had this working so this problem is minor.
:clarification:
The idea of the loop occurred to me because I have a list of images
"----for one in *.JPG; do--------"
from which I want to pluck images.
"--------sed s/image/$one/ gallery.tmplt >> gallery.html---"
So that when the script encounters the word (regex) it then replaces it with the next in the list. Where I have the difficulty is when I have multiple "image" instances in the page. I think I may be able to get the desired behavior with another loop, which increments "n", something like this;
------n=0 ------n=n+1 ------sed /n/s/image/$one/ gallery.tmplt >> gallery.html
Because I would like to replace all occurrences on a line with the current image. This would be useful for me to understand because I think I could implement the same simple technique to count the images per page.
Thanks for any help,
-e
Thanks, but that isn't what I am looking for... I have seen things that I might use... for instance http://www.smugmug.com/ or others on sourceforge or freshmeat but as I have previously mentioned, I would like to be able to change it and fix it (in essence 'hack' it) to suit my needs.
-e
Take a look at JAlbum, it may fulfill your needs without having to re-invent the wheel.
http://jalbum.net/en/software/download
-- Ken Schneider SuSe since Version 5.2, June 1998
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Fri, 05 Oct 2012 06:44:28 Eric Gunther wrote:
mentioned, I would like to be able to change it and fix it (in essence 'hack' it) to suit my needs.
The answer may be just to google around until you find examples you can template and adapt - there are lots of examples out there. On a similar search I found http://tympanus.net/codrops/2011/09/20/responsive-image-gallery/ plus http://fancybox.net/ These examples embed javascript in their pages so that you can do transition effects, popups and slideshows. Your requirements seem a little different than mine, so these two may not suit, but there are lots of examples out there. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Hi, Certainly, thank you for responding but no, not what I am looking for. I have looked around quite a bit, found numerous references. For instance searching for "bash script" is useful. Likewise, searching for "bash script html" comes up with useful info. thanks, -e On Fri, 2012-10-05 at 12:23 +1300, michael@actrix.gen.nz wrote:
On Fri, 05 Oct 2012 06:44:28 Eric Gunther wrote:
mentioned, I would like to be able to change it and fix it (in essence 'hack' it) to suit my needs.
The answer may be just to google around until you find examples you can template and adapt - there are lots of examples out there.
On a similar search I found
http://tympanus.net/codrops/2011/09/20/responsive-image-gallery/
plus
These examples embed javascript in their pages so that you can do transition effects, popups and slideshows. Your requirements seem a little different than mine, so these two may not suit, but there are lots of examples out there.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (4)
-
Eric Gunther
-
Ken Schneider - openSUSE
-
michael@actrix.gen.nz
-
Per Jessen