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.

Just coming back to this old post. I solved my issue using Hazel on my iMac, but ran into it today on my MacBook Pro, where I don’t currently have Hazel installed.

Why did the issue come up? Well, I’m chatting with Apple support about a broken iPhone. They requested a photo of it. So I snapped a photo and AirDropped it to my MBP to upload to the Apple support chat. I didn’t bother converting the HEIC. Well, here’s the error message I received in Apple’s own chat:
Screenshot 2020-02-02 08.50.28

I converted the file in Preview with no issue, but I still thought it was funny that Apple wouldn’t accept this file type. :laughing: