Skip to content

Instantly share code, notes, and snippets.

@AkdM
Last active January 20, 2024 08:26
Show Gist options
  • Save AkdM/9dbff2f85d34d8003907ad52bd648565 to your computer and use it in GitHub Desktop.
Save AkdM/9dbff2f85d34d8003907ad52bd648565 to your computer and use it in GitHub Desktop.
HEIC to JPG using terminal (in macOS)
# Add this to your .zshrc or .bashrc
# Use it by simply calling `heic2jpg pwd/picture1.heic pwd/picture2.heic pwd/picture3.heic`
# Only compatible with macOS. You can also change line 21 to make it compatible with something else.
# If you decide to delete source files, those will be in the bin, not deleted as with `rm` command.
# You will need imagemagick bin to convert the pictures: `brew install imagemagick`
heic_convert() {
echo "Converting $# .HEIC files to .jpg"
for var in "$@"
do
magick mogrify -monitor -format jpg $var
done
echo "Remove .HEIC files? [y/n]"
read remove_source
if [[ "$remove_source" == "y" ]]; then
for var in "$@"
do
osascript -e "tell application \"Finder\" to delete POSIX file \"${var}\""
done
fi
}
alias heic2jpg="heic_convert"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment