Created
March 15, 2022 20:44
-
-
Save mk270/364feb84eb7f5b4eed22f425cb162ad9 to your computer and use it in GitHub Desktop.
convert HEIC files in place
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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