/photography-gallery-generator

A bash script to prep (rename, resize, reduce, and watermark) a folder of images, and then generate an index in HTML

Primary LanguageShellMIT LicenseMIT

Photography Gallery Generator

This is a simple BaT bash script that:

  • Parses a folder of images (default: jpg)
  • Processes these image files (reduces, resizes, and applies a watermark) using ImageMagick
  • Generates an HTML index for use in a photography website

This bash script uses a bash template (BaT) called A-Bash-Template designed to make script development and command line argument management more robust, easier to implement, and easier to maintain. Here are a few of those features:

  • Dependencies checker: a routine that checks all external program dependencies (e.g., sshpass and jq)
  • Arguments and script details--such as script description and syntax--are stored in the JSON file format (i.e., config.json)
  • JSON queries (using jq) handled through wrapper functions
  • A script banner function automates banner generation, reading directly from config.json
  • Command line arguments are parsed and tested for completeness using both short and long-format argument syntax (e.g., -u|--username)
  • Optional command line arguments are permissible and managed through the JSON configuration file
  • Template functions organized into libraries to minimize code footprint in the main script

For more details about using a bash template, check out the BaT project here.

Example

See below for an example of both a processed image file and the resulting HTML index:

<!-- BEGIN Macro World gallery images -->
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_4208.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_9084.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_4732.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_3318.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp6631.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp2292.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_4988.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_3408__2_.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_1022.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_1462.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp0534.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp0042.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_3644.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_img_2855.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp3321_3.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_bbg.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_download003.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp1565.jpg" data-caption="" data-album="Macro World"></div>
<div class="file" data-type="image" data-source="./images/work/macro_world/reduced_imgp5595.jpg" data-caption="" data-album="Macro World"></div>
<!-- END Macro World gallery images -->

IMPORTANT: This Project Uses Git Submodules

This project uses Git submodule project(s) (located in the bash-lib folder) to keep this project up-to-date without manual intervention.

Be sure to clone this project with the --recursive switch (git clone --recursive https://github.com/richbl/this_project) so any submodule project(s) will be automatically cloned as well. If you clone into this project without this switch, you'll likely see empty submodule project folders (depending on your version of Git).