Organizing iPhone Media by their Types

iPhones (and iPads) have limited file management capabilities we all know this. This affects how well you're able to filter through your media. The most common pain point for me is having no choice but to see screenshots and everything else interspersed with the photos I actually want to see.

To be fair, iOS does provide filtering by type, specifically these types:

Notice something missing? Photos! There is no filter available to only see your photos. The closest thing you can do is to filter to Live Photos, but that does not include any non-Live photos. Non-Live happens more often than you think, such as for long-exposure night photos and photos you take during videos (or you simply turned off Live).

Photos aren't the only issue with the provided filters. The "Videos" filter includes camera videos and screen recordings even though "Screen Recordings" is its own filter. So there is also no way to view only your camera videos without screen recordings mixed in! Let's try to solve all of this.

So how can you filter to only seeing your photos, without the distraction of screenshots, videos, etc. mixed in?

I don't have a solution on the iPhone itself (Apple, please fix this!), but I do export all of my media to a NAS (network-attached storage) and have written a tool to help separate them there. Once the tool finishes processing your files, it outputs a simple report like this:

Copying /media/iphone/all_media/IMG_1551.HEIC to /cameras/iPhone 13/IMG_1551.HEIC
Copying /media/iphone/all_media/IMG_1552.HEIC to /cameras/iPhone 13/IMG_1552.HEIC
Copying /media/iphone/all_media/IMG_1553.HEIC to /cameras/iPhone 13/IMG_1553.HEIC
Copying /media/iphone/all_media/IMG_1554.HEIC to /cameras/iPhone 13/IMG_1554.HEIC
Copying /media/iphone/all_media/IMG_1555.HEIC to /cameras/iPhone 13/IMG_1555.HEIC
Copying /media/iphone/all_media/IMG_1551.MOV to /cameras/iPhone 13/IMG_1551.MOV
Copying /media/iphone/all_media/IMG_1547.MOV to /cameras/iPhone 13 Videos/IMG_1547.MOV
Copying /media/iphone/all_media/IMG_1548.MOV to /cameras/iPhone 13 Videos/IMG_1548.MOV
Copying /media/iphone/all_media/IMG_1550.PNG to /media/iphone/screenshots/IMG_1550.PNG
Copying /media/iphone/all_media/IMG_1549.PNG to /media/iphone/screenshots/IMG_1549.PNG
Done!

Handled:
5 new camera photos.
1 new videos from live photos.
2 new camera videos.
2 new screenshots.

NOTE: As of 2023-07-06, the tool supports separating Photos/Live Photos, Videos, Screen Recordings, and Screenshots, but it cannot differentiate between your photos and those that were sent to you (via AirDrop or otherwise). Below I detail how this tool works today, and include sections about how I plan to support AirDrop in the future.

How does it work?

With the help of ExifTool and MediaInfo, the script can find hints in the metadata to make educated guesses about the type of each file. Below I will outline my logic for each type.

Is it an iPhone photo?

Not every JPEG or HEIC file is a photo taken by your device it could have just been a funny meme you downloaded or a drawing you saved. It could have also been AirDropped to you.

Let's first address how to determine if a photo was taken by the iPhone's stock camera app. Note: I am considering third-party camera apps as out-of-scope.

All photos from the camera app have metadata and provide two key data points:

  1. The maker of the lens. In this case, we want EXIF:LensMake or EXIF:Make to say "Apple".

  2. The model of the lens. In this case, we want EXIF:LensModel or EXIF:Model to include "iPhone" or "iPad".

Easy. Any picture that lacks this metadata will not be included.

What about photos from AirDrop?

This gets complicated. iOS does not provide any mechanism to distinguish between your own photos and photos from others. There is metadata about the model of iPhone that took the photo, but it's too easy for a friend to have the same model. That said, there are two methodologies I found and will leverage both for the tool.

1) Boot Time

There is a combination of fields that can help us identify a specific device:

  1. Composite:RunTimeSincePowerUp contains the device's uptime in seconds.

  2. EXIF:DateTimeOriginal gives the time the photo was taken.

  3. EXIF:OffsetTimeOriginal defines the timezone for the given time.

Not sure why Apple opted to include the device's uptime in each photo taken, but we'll use it! With the uptime and date info available, we can calculate when the device last booted up. We can then group up the photos by their shared boot times.

... Just don't turn your phone on at the exact same second as a friend! But even if you do, it shouldn't matter:

2) Filename Numbers

iOS increments a single counter when numbering all types. Here's an example list:

FilenameType
IMG_1592.PNGscreenshot
IMG_1593.PNGscreenshot
IMG_1594.MOVvideo
IMG_1595.HEIClive photo
IMG_1595.MOVlive photo's video
IMG_1596.MOVvideo
IMG_1597.PNGscreenshot
IMG_1598.HEIClive photo
IMG_1598.MOVlive photo's video

If we depend on iOS's file-naming behavior (and all files have their original filenames), and combine that knowledge with the Date Taken/Created, we can pretty accurately identify one device from another even if they have overlapping file numbers.

Unfortunately, there needs to be some interaction to make this work. The tool can use the two methodologies to group up files to their respective devices, but it is unable to identify which group is your device.

We could make assumptions like "the device with the most photos must be the owner's", but it's possible that a peer is a far more prolific photographer. Or maybe the device with the most screenshots would be the owner's since it's unlikely that people are AirDropping screenshots... but is that always going to be true? Some owners might not take screenshots at all!

I don't think there are any 100% reliable assumptions we can make, so the best course of action is to prompt the user to check on a photo(s) from each group and answer whether that photo is their own.

Is it an iPhone video?

Just like with photos, not every MOV file is a video taken by your device. And here's the kicker: the video portion of Live Photos is not embedded into the image file (like is the case on some Android phones) and ends up saved as a separate MOV file. I am in the school of thought that these "Live Photo videos" should be kept alongside their corresponding photos and, therefore, should be treated differently from regular video recordings.

Fortunately, with the help of MediaInfo, there are some metadata clues we can use:

  1. Video recordings have a comapplequicktimemake field that says "Apple".

  2. Live Photo videos have a livephoto field.

AirDrop?

While photos have a field to help group by boot time, videos don't have that data. But the filename methodology is still viable.

Is it a screenshot?

We can use ExifTool to parse two fields:

  1. The ICC_Profile:DeviceManufacturer or ICC_Profile:PrimaryPlatform field should say "APPL".

  2. The EXIF:UserComment field should say "Screenshot".

AirDrop?

Same with videos, we are limited to using the filename methodology.

Is it a screen recording?

For whatever reason, these files are MP4 instead of MOV, so that is already one differentiator. And of course, to differentiate from any other MP4, we can use metadata.

The performer field should say "ReplayKitRecording".

AirDrop?

We are limited to the filename methodology.

In an ideal world, we shouldn't need this tool.

I just detailed a lot of thought and effort that went into working around a limitation of iOS. I want to make it clear that I wish I didn't need to do this at all. Credit where credit is due, we must compare with the competition. Android allows you to navigate the folder structure and avoids the problem:

WhatWhere
Camera photos (including Live)Image files in DCIM/Camera
Live photo videosEmbedded into the image files in DCIM/Camera
Camera videosVideo files in DCIM/Camera
ScreenshotsPictures/Screenshots
Screen recordingsFiles that start with "screen" in Movies
Anything received from othersDownload

A human can navigate to what they want on their own without the need for some tool(s) people put online. Isn't that better?

As things are now though, enjoy my tool! Hope you find it as useful as I do.

To be continued...

As mentioned before, I still need to design and implement support for differentiating between your photos and those shared to you. I will save that for a followup post.