Shell Scripts for ProGallery Management


# Get the base name, create a _tn version, downsize the _tn to a max of 1280 pixels,
# and copy them to the target gallery. (Future: add a command line arg for gallery)

a=`basename -s .jpg $1`
cp $a.jpg ${a}_tn.jpg
sips -Z 1280 ${a}_tn.jpg
mv $a.jpg /Volumes/wwwroot/Pictures/Food
mv ${a}_tn.jpg /Volumes/wwwroot/Pictures/Food

# I use ProGallery - https://stacks4stacks.com/progallery/
# ProGallery uses a CSV file as the image directory source.
# The first line is labels: Title, ThumbnailPath, ImagePath.
# Images are displayed in order, so we need to add the labels
# and the
new images *at the top*. Also, Title can include HTML, so I do.

# Strip off the header of the existing file.
grep -v Thumbnail /Volumes/wwwroot/Albums/Food.csv > /Volumes/wwwroot/Albums/Food.csv.o
# Delete the existing file.
rm /Volumes/wwwroot/Albums/Food.csv
# Create the labels for the new file
echo \"Image\", \"Thumbnail\", \"Fullsize\" > /Volumes/wwwroot/Albums/Food.csv
# Add the new image
echo '"'${a}'
'${a}'"', ../Pictures/Food/${a}_tn.jpg, ../Pictures/Food/${a}.jpg >> /Volumes/wwwroot/Albums/Food.csv
# Concatenate the old list of images to the end
cat /Volumes/wwwroot/Albums/Food.csv.o >> /Volumes/wwwroot/Albums/Food.csv
# Delete the old image list
rm /Volumes/wwwroot/Albums/Food.csv.o
# Open the gallery file to edit the Title.
open -a /Applications/BBEdit.app /Volumes/wwwroot/Albums/Food.csv