logo

dmpop

Aircraft photography, spaghetti code, half-baked thoughts

Reads Guestbook
Currently reading: Damascus Station, David McCloskey


Faster, simpler upload to Internet Archive with a Bash script

I upload many of my photos and RAW files to the Internet Archive, but its web-based uploader is slow and clunky.

Fortunately, the Internet Archive offers a command-line tool, so I've cobbled together a Bash script for uploading JPEG and RAW files.

#!/usr/bin/bash

if [ ! -x "$(command -v ia)" ] || [ ! -x "$(command -v yad)" ] || [ ! -x "$(command -v exiv2)" ]; then
echo "Make sure that ia, exiv2, and yad are installed."
exit 1
fi

creator="Your name goes here"
license="https://creativecommons.org/licenses/by/4.0/"

filename=$(basename -- "$1")
title="${filename%.*}"
keywords=$(exiv2 -g Keywords -Pv "$1" | tr '\n' ',')
subject=$(echo "$keywords" | yad --text-info --center --width=400 --height=200 --editable --wrap)
imagedescription=$(exiv2 -g Exif.Image.ImageDescription -Pv "$1")
description=$(echo "$imagedescription" | yad --text-info --center --width=400 --height=200 --editable --wrap)
dt=$(exiv2 -g Exif.Image.DateTimeOriginal -Pv $1 | cut -d' ' -f1 | tr ':' '-')

ia upload "$title" $1 $2 \
--metadata="mediatype:image" \
--metadata="collection:opensource_image" \
--metadata="title:$title" \
--metadata="description:$description" \
--metadata="subject:$subject" \
--metadata="creator:$creator" \
--metadata="date:$dt" \
--metadata="licenseurl:$license"
  1. Copy and paste the code above into a text file.
  2. Save the file under the ia.sh name in the ~/bin directory.
  3. Make the script executable using the chmod +x ~/bin/ia.sh command.
  4. Install the ia command-line tool as well as the yad and exiv2 packages on your system.

To upload a JPEG+RAW pair, use the following command:

ia.sh img.JPG img.RAW

A few notes:


Published: 2024-07-03Reads: 58
Back
Me

Me

Linux user, amateur photographer, aviation enthusiast, clueless developer of ADS-B station, Pellicola and Tinble, author of a bunch of books. I can mix a decent Negroni, too. You can reach me at me@dmpop.xyz