Mailinglist Archive: opensuse (924 mails)

< Previous Next >
Re: [opensuse] bash script to build html gallery
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@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References