Skip to content

Instantly share code, notes, and snippets.

@dacr
Created December 15, 2025 17:29
Show Gist options
  • Select an option

  • Save dacr/f6a3ba1b0318f7f8e8363fa08d36890c to your computer and use it in GitHub Desktop.

Select an option

Save dacr/f6a3ba1b0318f7f8e8363fa08d36890c to your computer and use it in GitHub Desktop.
Convert iphone HEIC photo to PNG / published by https://github.com/dacr/code-examples-manager #533ad129-77f7-4664-9871-67f96c0bcea2/d523556f5b1e1663ddc4f313cfc878f12f1d0c89
## summary : Convert iphone HEIC photo to PNG
## keywords : bash, iphone, HEIC, PNG, convert
## publish : gist
## authors : David Crosson
## license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
## id : 533ad129-77f7-4664-9871-67f96c0bcea2
## created-on : 2025-08-24T17:39:02+02:00
## managed-by : https://github.com/dacr/code-examples-manager
## run-with : sh $file
# Enable case-insensitive globbing
shopt -s nocaseglob
for INPUT in *.heic; do
# Extract the extension with its original case
EXT="${INPUT##*.}"
# Create output filename by replacing the original extension
OUTPUT=$(basename "$INPUT" ".$EXT").png
echo "====================================================================="
echo "-- converting '$INPUT' to '$OUTPUT'"
echo "---------------------------------------------------------------------"
if [ ! -f "$OUTPUT" ]; then
magick "$INPUT" "$OUTPUT" && rm -f "$INPUT"
else
echo "Output file '$OUTPUT' already exists, skipping."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment