Skip to content

Instantly share code, notes, and snippets.

@openly-retro
Created November 25, 2025 03:19
Show Gist options
  • Select an option

  • Save openly-retro/140a75e5162fe3bca9f4645cae30e332 to your computer and use it in GitHub Desktop.

Select an option

Save openly-retro/140a75e5162fe3bca9f4645cae30e332 to your computer and use it in GitHub Desktop.
Use Imagemagick to convert a HEIC image to JXL and rename based on original creation date
#!/bin/bash
sourcefile=$1
sourcefilenoext="${sourcefile%.*}"
sourceasjxl="${sourcefilenoext}.jxl"
SECONDS=0
# conversion to jxl (JPEG-XL)
magick mogrify -format jxl $sourcefile -define preserve-timestamp=true
# Copy EXIF tags
exiftool -tagsFromFile $sourcefile $sourceasjxl
# rename the JXL based on the datetime
exiftool "-filename<datetimeoriginal" -d "%Y%m%d_%H%M%S.%%e" $sourceasjxl
# rm $sourceasjxl
rm "${sourcefilenoext}.jxl_original"
duration=$SECONDS
echo "Done in $((duration / 60)) minutes and $((duration % 60)) seconds."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment