Apple isn’t known for playing nice with others, and sometimes — just like Google and Microsoft and Facebook and others — their behaviour borderlines on the anti-consumer.
If you have ever tried to get images from your iPhone onto a PC, you may have encountered such a situation.
The Problem
Many of the images an iPhone will take are stored in “.HEIC” format. It is, as it is named, a higher efficiency format (takes up less space). The problem is that most PCs don’t natively support this format (This is changing). So this is a classic case of “We’re trying to set a trend by changing things to this format … but nobody’s following us”.
Gone are the days where Apple did anything innovative, and now they have resorted to strong-arming their customers into certain paradigms. I must say, this is not unique to them, plenty of their competitors do this and it is a cause for concern — but that is for another blog post.
So how do I get my standard jpg or png out of an HEIC?
There are plenty of apps that you can download to do this, but I’m a tinfoil-head type, and don’t trust single-use apps of that nature — Too many virus-related risks. So I did some research on my own.
My Solution
I’m a programmer at heart, so I went to script route:
for entry in $(find . -name "*.MOV"); do
f=$(basename -- "$entry");
ffmpeg -i "$entry" -frames:v 1 "$f".jpg; done
What is going on above? It takes all the .MOV files in the directory (and subdirectories) and converts them to <name>.mov.jpg. It saves the new jpg to the place where the script is run.
Explanation
Sadly, FFmpeg (My standard conversion tool for such tasks) does not currently support HEIC formats. This complicates things. But I noticed that each ‘live image’ that the iPhone took created two files: a “.HEIC” and a “.MOV” — which is just a 3-second movie. I chose to simply take the first image of that movie as the picture.
‘Basename‘ is a useful bash command that strips the filename (basename) from a full path.
I use ffmpeg for this. Download it, and put it somewhere where in your path. I used gitbash for my scripting. If you use gitbash, you can simply copy-paste the ffmpeg exes into the “C:\Program Files\Git\cmd” path (default).
Then open up gitbash and run the script. In modern Windows, you might have to hold SHIFT then right-click to get the ‘Open Git Bash Here’ menu item.
Also, you can change the output files to .png if you like.
Connecting To Your iPhone
This all requires you to connect your PC to your iPhone.
Do this by following the steps below:
- Unlock your iPhone.
- Connect the iPhone to your PC via USB cable.
- If your iPhone detects the connection, it might ask if you want to allow access — Allow it.
- Your iPhone should be recognized as a device on your PC. Go to ‘My Computer’ and open it like any removable drive.
Preventing This in the Future
If you always want your iPhone to save images as JPEG, on your iPhone…:
- Go to ‘Settings’ -> Camera -> Formats
- Select ‘Most Compatible’
It will now save files in the most compatible format available (JPEG and H.264)
Sources
- Apple Support: https://support.apple.com/en-ca/120267
- Git (Contains Git Bash): https://git-scm.com/downloads
- FFmpeg Conversion Tool (Very Powerful): https://www.ffmpeg.org/
- https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format
- Linux Libraries for HEIC Conversion: https://stackoverflow.com/questions/65435536/convert-a-heif-file-to-png-jpg-using-ffmpeg