1

I have a folder where there are many pictures taken with my iPhone. Turns out that half of them are JPGs and half of them were supposed to be HEIC format.

For some reason, all pictures in this folder are with JPG extension, check this image: https://i.sstatic.net/wHzT8.jpg

First, I thought that other JPGs were corrupted files, as you can see in the image above that I got an error when I try to open them. Then, I realized they were supposed to be HEIC and not JPG, because they were Apple Live Photos. When I manually renamed couple of those JPG files that were not opening to HEIC format, they could open correctly as a short video, because they were live photos.

My question is: Is there a way to find all these false JPG files that do not open and rename them from .JPG to .HEIC? I can't just rename all JPGs to HEIC because the other pictures are not live photos.

1 Answer 1

0

If you have a command line program that can open JPG files but not HEIC you could run this program and use its exit code to determine if the file was a valid JPG or not.

You can try the convert program from imagemagick.

untested example:

for jpg in *.jpg do heic="${jpg%.jpg}.heic" # construct HEIC file name tmp="$jpg.png" # temporary PNG file if ! convert "$jpg" "$tmp" # try to convert then mv "$jpg" "$heic" # rename if conversion failed fi rm -f "$tmp" # PNG no longer needed done 

Of course this doesn't work if the convert program accepts HEIC files as input.

The example code was inspred by this: https://github.com/williamthing/Scripts/blob/master/Shell/jpg2png.sh

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.