Simple Html Image Gallery - From A Simple Linux Shell Script

Linux Html Image Gallery Creator
Linux Html Image Gallery Creator
Create A "Rightclick-Select-Select" Html Image Gallery For Puppy Lucid51 Linux

[Updated: 23 August, 2013. 
Please note that whether you copy/paste code or download the tar file, there is an important step which may not be obvious, and that is to change the browser executable name at the end of the exec script(lh_img_gallery) before running the install  script( This step is important. Read on.]

Did you know how I used Font3dTemplates to create impressive wordart images for use at my website? Just take a look at the top of my Homepage. While busy with this task, I needed an image gallery to view all images in one page, and came up with this simple image gallery shell script[currently for offline use only]. 

All you need to do is to [rightclick] on an image directory and select [Open With] first and then select [lh_img_gallery] from the menu to create the image gallery where you can click on individual thumbnails to view them in full size in a new tab. Developed and successfully tested on Puppy Lucid51, this image gallery creator should work well on other linux and unix flavors as is or with minimum modifications [at least Usage 2:CLI described towards the end of this article].

Let me explain briefly what is involved in getting it done. 

Start simple. Create the scripts first.

Script 1: The main script

#lh_img_gallery - Linux Html Image Gallery Creator

#1.GUI: Open Rox file manager,  rightclick on a directory with images, select
#  [Open With] and then select [lh_img_gallery] to generate the image gallery
#  and open it with your browser.
#2.CLI: You can also open a rxvt terminal and type
#  /root/my-applications/lh_img_gallery/lh_img_gallery your-image-directory-with-full-path
#  to run and view the gallery.
#  eg. /root/my-applications/lh_img_gallery/lh_img_gallery /mnt/sda1/TRAV/tmpcd/CMisc
#Jerome Christopher
cd "$dir"
echo '<html><body><div style="text-align:center;float:left">Linux Html Image Gallery<br>'>$outfile
*.jpg *.jpeg *.bmp *.png *.gif|while read pic; do
echo '<a href="'$dir/$pic'"'' target="_blank"''><img src="'$dir/$pic'"
width="100" height="50" border="1"
echo '</div></body></html>'>>$outfile

chrome "file:///$outfile"
Note1: Change image types in red to add/remove image file types.
Note2: Change the thumbnail width and height in blue to resize thumbnails.
Note3: Change the browser in lightgreen to open your browser.

Script 2: The install script

#Install files at /root/my-applications/lh_img_gallery and make a link for
#lh_img_gallery at /root/.config/
#Jerome Christopher
mkdir $installdir
cp lh_img_gallery $installdir
cp $installdir
cp $installdir
cp $installdir
ln -s $installdir/lh_img_gallery /root/.config/
)>/tmp/lh_img_gallery_install.out 2>>/tmp/lh_img_gallery_install.out
geany /tmp/lh_img_gallery_install.out

Script 3: The uninstall script

#Uninstall the lh_img_gallery
#Jerome Christopher
rm -f $installdir/lh_*
rmdir $installdir
rm -f /root/.config/
)>/tmp/lh_img_gallery_uninstall.out 2>>/tmp/lh_img_gallery_uninstall.out
geany /tmp/lh_img_gallery_uninstall.out

Script 4: The check script

ls -l /root/.config/*
cd /root/my-applications/lh_*
ls -l lh_*
ls -l /tmp/lh_img_gallery_install.out
cat /tmp/lh_img_gallery_install.out
ls -l /tmp/lh_img_gallery_uninstall.out
cat /tmp/lh_img_gallery_uninstall.out
)>/tmp/lh_img_gallery_check.out 2>>/tmp/lh_img_gallery_check.out
geany /tmp/lh_img_gallery_check.out

Implementation Considerations

I remembered to make these scripts executable and changed permissions appropriately. I also was wondering how to run these easily. Luckily the Rox file manager has  the [/root/.config/] folder configured in a way that will allow me to drop my  executable links there. All I needed to do was to create a link for the [lh_img_gallery] script and drop it in the [/root/.config/] folder. Now I could rightclick on a directory,  select [Open With] and then click on [lh_img_gallery] to generate and view the image gallery.  

Install and Usage


Method 1: Download tar

1.Download the tar file from here.
2.Go to a temporary directory[eg. /tmp] and extract the tar file there to create and copy files to the [/tmp/lh_img_gallery.install] directory.
3.Go to the /tmp/lh_img_gallery.install directory and change the file permissions[chmod 755 lh_*]
   4.Change the browser executable name (eg. chromium-browser, firefox, opera 

      etc with path) at the end of the executable script (lh_img_gallery) before 
      running the install script ( This is important.]
5.Click on the /tmp/lh_img_gallery.install/ script to install.
6.Click on the /tmp/lh_img_gallery.install/ script to verify install.

Method 2: Copy/Paste

1.Create a test directory [mkdir /tmp/lh_img_gallery.install] and copy and paste all 4 scripts there. 
2.Change to the /tmp/lh_img_gallery.install directory, change the file permissions[chmod 755 lh_*]. 
   3.Change the browser executable name (eg. chromium-browser, firefox, opera etc with path) 
   at the end of the executable script (lh_img_gallery) before running the install script 
   ( This is important.]
4.Click on to install. 

Remember that the uninstall script will remove the install directory with the 4 scripts, the link, and the output file.


Click on /tmp/lh_img_gallery.install/ to uninstall.


1.GUI: Open Rox file manager,  rightclick on a directory with images, select [Open With] and then select [lh_img_gallery] to generate the image gallery and open it with your browser.
2.CLI: You can also open a rxvt terminal and type
/root/my-applications/lh_img_gallery/lh_img_gallery  your-image-directory-with-full-path to run and view the gallery.
eg. /root/my-applications/lh_img_gallery/lh_img_gallery  /mnt/sda1/TRAV/tmpcd/CMisc

Final Words

First looks may be deceptive, let's jump up to the top for another look at our Simple Linux Html Image Gallery. Not too bad for a 10-line shell script image gallery creator, I think! How about you?


Blog Collage - Top Random Posts In No Particular Order

Mouseover the images for title and comments