- [Instructor] Hi, and welcome to
the next video of Section Five,
Web Photo Album Generator.
In the previous video,
we've seen about Image Crawler and Downloader.
In this video, we'll show you how to generate
a web photo album.
Web developers commonly design photo album pages
for websites that consist of a number
of image thumbnails on a page.
When thumbnails are clicked,
a larger version of the picture will be displayed.
However, to do this, many images are required.
Afterwards, copying the image tags,
resizing the image to create a thumbnail,
placing them in the thumbs directory,
and so on, is a real hurdle.
As with any repetitive task, this can be automated easily
by writing a simple bash script.
By writing a script, we can create thumbnails,
place them in the exact directories,
and generate the code fragment for image tags
automatically in a few seconds.
We can perform this task with a for loop,
that iterates every image in the current directory.
The usual bash utilities, such as cat and convert,
from the image magic package you used.
These will generate an HTML album,
using all images to index or HTML.
Let's write a bash script to generate
an HTML album page.
Run the script as follows.
Let's see how it worked.
The initial part of the script
is used to write the header part
of the HTML page.
The following script redirects all the contents
up to EOF1 to index.html.
The header includes the HTML and CSS styling.
This will iterate through the names of each file,
and we're performing necessary actions.
This will create images of 100 pixels wide as thumbnails.
The following statement will generate
the required image tag, and append it to index.html.
Finally, the footer HTML tags
are appended with cat, as well.
Awesome, we successfully learned
how to generate a web photo album.
In the next video,
we'll learn how to create a "define" utility,
by using the web backend.