Folder Action for HEIF images to JPG

I often need to take photos using my iPhone and then get them to my Mac for uploading to a web service or putting into an app. So I created a service using Automator that will convert the .HEIC images to .JPG. This works well, but I was thinking it would be nice to just automatically do this.

When I airdrop an image from my phone, it shows up in the Downloads folder. So I thought about creating a folder action for that folder, but I worry that could raise some issues since so many things get sent here.

And I can’t see a way in Automator to only do an action IF the file type is HEIC.

I suppose I could use Hazel, but I don’t currently run it after not using it much.

Any thoughts?

I just discovered this, and despite it being a year old, I realized that I’ve basically solved the same issue, except that I didn’t use Automator and Folder Actions, I used Hazel and ImageMagick in a shell script.

#!/usr/bin/env zsh -f

PATH='/usr/local/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin’

if ((! $+commands[magick] ))
then

	# note: if magick is a function or alias, it will come back not found

	echo "$NAME: 'magick' is required but not found in $PATH" >>/dev/stderr
	exit 1

fi

if ((! $+commands[tag] ))
then

	# note: if tag is a function or alias, it will come back not found

	echo "$NAME: 'tag' is required but not found in $PATH" >>/dev/stderr
	exit 1

fi

for i in "$@"
do

	EXT="$i:e:l"

	if [[ "$EXT" == "heic" ]]
	then

		JPG="$i:r.jpg"

		if [[ -e "$JPG" ]]
		then

			echo "$NAME: '$JPG' already exists. Skipping." >>/dev/stderr

		else

			magick convert "$i" "$JPG”

			tag --add "Converted" "$i" "$JPG"

		fi
	fi
done

exit 0

I call that script from within Hazel whenever it finds an HEIC file that does NOT have the ‘Converted’ tag.

99.999% of the time the HEIC was AirDropped, and if it wasn’t, there’s still no harm in making a JPG version of it.

Anyway, I thought I’d mention it in case anyone else was looking to do the same thing.