Skip to content

Instantly share code, notes, and snippets.

@mk270
Created March 15, 2022 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk270/364feb84eb7f5b4eed22f425cb162ad9 to your computer and use it in GitHub Desktop.
Save mk270/364feb84eb7f5b4eed22f425cb162ad9 to your computer and use it in GitHub Desktop.
convert HEIC files in place
#!/bin/bash
# Warning: converts file in place
# Usage:
# convert-heic kittens009142.heic
set -eu
if [ $# != 1 ]; then
echo Usage: convert-heic filename.HEIC
exit 1
fi
filename=$1
unrecognised () {
echo Unrecognised file extension
exit 1
}
do_conversion () {
local base="$1"
local dir="$2"
local target="${base}.jpeg" # da da da
tifig "$filename" > "$dir/$target"
rm -f "$filename"
}
d=$(dirname "$filename")
case "$filename" in
*.HEIC) do_conversion "$(basename "$filename" .HEIC)" "$d" ;;
*.heic) do_conversion $(basename "$filename" .heic) "$d" ;;
*) unrecognised ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment