Inside and Out of Photos for Mac
Do you know where your photos really are?
There’s a lot you can do with Photos, and a lot you can’t. Apple takes good care of your photos, but leaves limited control with you. Using the photos outside of the app or exporting them exactly as you want isn’t easy.
There are many reasons why you might want to access and use your photos directly, i.e. outside of Apple’s Photos app:
- To export your past 10 years’ favorite photos for making yearbooks.
- To convert your neatly-curated event albums into beautiful photo books.
- To have a real backup on external HD. iCloud isn’t a backup, you know!
- To move to another photo management program or (uh) Windows PC
- Because they’re yours, goddamn it, and you want control over them.
Where Are Your Photos?
The original, unedited, full-sized versions of the items that you see in the All Photos tab of Mac Photos can be in one of these three places:
- In the Photos library. Called “managed” or “local” files
- In the iCloud Photos library
- In folders on the Mac or in an external drive. Called “referenced” files
As for photos that have been edited, and albums, it’s a bit more complicated.
Welcome to a tour of the engine room of Mac Photos, including an insight into the databases that power everything you see and do in Photos. We’ll first explore the simple case where everything is saved in the Photos library itself. We’ll then look at iCloud Photos and referenced files.
The Photos Library
The door to Mac Photos’ secret cave is the Photos library icon. It’s normally in the Pictures folder, unless you’ve moved it elsewhere. If you have more than one Photos library, you’ll have one icon for each library.
The Photos library is a package file — basically a folder adorned with the Photos app icon. This folder has several folders and sub-folders to store the photos and videos, and a database that holds every little detail about them. The package file’s name is Photos library.photoslibrary
.
Double-clicking the Photos library icon opens the Photos app, not the package file. To look in the package file, right-click or control+click the Photos library icon, and select Show Package Contents in the menu.
A word of caution: Don’t modify, move or delete any of the Photos library package’s contents, as this may corrupt and render the library unusable.
The Folder Structure
The folders you see on selecting Show Package Contents vary, depending on which version of Photos you have:
In recent versions of Photos, original photos reside in the Originals folder, in sub-folders named 0–9 and A-F. The original file names (e.g. IMG_237) and Titles (that you’ve added) are changed to “GUID” names like C77F6C93–398B-4363–8254–6DC90834D2E. These “globally unique identifiers” allow Photos to keep track of each photo, its edit history, and all its attributes.
In Mojave and earlier, the original files resided in the Masters folder. The folder structure was more human-friendly than it is now. There used to be one folder for each year, e.g. 2014, 2015 etc.; and each year had sub-folders for every month for which photos existed, e.g. 01 for Jan, 02 for Feb etc.
The Resources folder in all versions of Photos for Mac contains a multi-level sub-folder hierarchy to store image thumbnails, face thumbnails, JPG versions of photos that have been edited, shared albums and much more.
The Database folder contains SQL (Structured Query Language) databases that govern everything in Photos. The contents of these databases differ in every version of Photos. This is why you can’t open a Monterey library on a Mac running Sequoia, or a Big Sur library on a Catalina Mac. Apple lets you migrate the Photos library from an older to newer version of Photos, but reverting to an older version is quite tedious (Although not impossible).
The remaining folders e.g. External, Private, Resources, Scopes etc. are for internal purposes and of little interest to most of us.
Edited Photos, Albums and Special Types
Well, we found our unedited photos, but where are the edited photos kept? The short answer: Nowhere. They are generated on the fly, when needed. This is far more efficient than storing the original and every single edited version for each photo. Photos generates the edited versions only when exporting them — it takes the original unedited photos, applies the editing instructions stored its database, and adjusts them according to the export options that you specify. The edited version isn’t created when you view a photo — what you see is its slightly scaled down JPG rendition incorporating the latest edits, which Photos stores in the Resources folder.
Albums are also generated only when you open them. Photos stores their details — album names, which photos they contain and the sequence — and with this creates an album view when you ask. Thus, adding photos to albums doesn’t use extra space because Photos still has only one copy of each photo. Likewise, deleting photos from albums doesn’t free up space — it only amends the database records. If you delete a photo from an album, it still stays in Photos library and in other albums to which it belongs — but deleting a photo from the library deletes it from all the albums.
As for special photo types: Live photos are stored as a combination of .jpg
and .mov
files, and can only be viewed within Photos. Burst is a sequence of shots captured by iPhone at 10 frames/sec. So a 9 sec burst has 90 frames, but Photos only shows you one frame. The rest stay in the library with isHidden
pointer until you click review and decide which to keep.
The Photos Database
The engine that drives Photos is an SQL database. It’s named Photos.sqlite
in Catalina and later, and Photos.db
in Mojave and older macOS’s.
These databases contain several tables that store data needed to synthesize all of Photos’ features. Here is a summary of what these databases contain:
The databases in Photos for Monterey and Ventura are mostly like Big Sur, with a few tables renamed or added. The changes from Ventura to Sequoia mostly relate to Apple Photos’ AI and face/pet recognition features. The important tables and their contents are as follows:
The table ZASSET (named ZGENERICASSET in Catalina and RKMASTER in Mojave and older) contains records for each photo and video identifying its file name, title, size, storage location, file path; whether edited, favorite, grouped, whether belonging to a shared album, recently deleted, hidden, live, depth or burst photo; and a lot more.
The Photos app also runs a background process “photo analysis”. Among other things, it assigns quality scores to your photos, and stores a lot of this data in ZASSET table, in columns named ZOVERALLAESTHETICSCORE and ZCURATIONSCORE. These, and scores in ZCOMPUTEDASSETATTRIBUTES (See below) can help surface your best photos. One day it could be used to cull technically poor photos — shaky, blurry, too dark, low res etc.!
ZADDITIONALASSETATTRIBUTES stores information about the photo or video’s orientation, time zone, original file size, original dimensions, view count, deletion status, and pointers to information stored in other tables.
ZCOMPUTEDASSETATTRIBUTES is where Photo app’s algorithm “grades” your photos on factors such as harmonious colors, interesting subject, pleasant camera tilt, composition, lighting, perspective, symmetry, sharp focus, good framing etc. These drive Photos’ machine learning-powered features like Memories, Days, and For You. Learn more here.
ZEXTENDEDATTRIBUTES stores EXIF metadata, such as camera make and model, shutter speed, aperture, focal length, ISO, metering mode, GPS data etc. In Big Sur, ZEDITEDIPTCATTRIBUTES table keeps IPTC metadata used by Photos and other programs for search and organization.
Tables Z_26ALBUMS, Z_26ASSETS and Z_36KEYWORDS in Photos for Big Sur become Z_27ALBUMS, Z_27ASSETS and Z_38KEYWORDS, respectively, in Monterey. In Sonoma and Sequoia, they are further incremented.
ZPERSON, ZDETECTEDFACE, ZDETECTEDFACEGROUP are some of the tables that store face recognition data.
All the features you enjoy in Apple Photos are powered by the above data. From sorting photos, creating albums (and smart albums), non-destructive editing, face recognition, image search, syncing via iCloud — everything is a combination of the original unmodified photos and this data.
Apple could add many more cool features by using the existing info in the database. Example: To let you sort the library by file size. This would be useful, e.g. if you’re out of iCloud storage and want to offload your largest files to an external drive (But that won’t be good for Apple, would it? 😉)
Let’s now look at the two remaining places where photos may be stored — in iCloud and in other locations outside of the Photos library.
iCloud-based Photos
When you use iCloud and iCloud Photos Library, photos from all connected Apple devices — your Mac, iPhone and iPad — are stored in iCloud Photos Library and are synced across all those devices. However, what gets stored in the Photos library on your Mac depends on the source of the photos:
- Uploaded from Mac Photos library: For items first imported into Mac Photos and then synced with iCloud Photos, full resolution photos are normally saved in the Photos library as well as iCloud Photos — even if you’ve opted for ‘Optimize storage’ in Settings. Only when the Mac’s disk is getting full, Photos will manage storage by creating lower resolution images for the Mac, and keeping full sized photos in iCloud Photos.
- Uploaded from other devices: By default, full resolution original photos stay in iCloud Photos and the source device (e.g. iPhone), and syncing saves their thumbnails and smaller sized JPG copies in the Mac Photos library. When you click such a photo’s thumbnail in Mac Photos, the full sized photos are downloaded from iCloud — at which point both iCloud Photos and the Mac Photos library have full resolution photos.
You can view, delete, share and download photos directly from your iCloud Photos library as explained in this tutorial.
Referenced Files
These are photos and videos stored outside the library, e.g. on an external drive. The Photos library only keeps “references” to them. To create such files, uncheck ‘Copy items to Photos library’ in Photos Settings, then drag the items into Photos. The full-size originals will stay on disk, and Photos will create references i.e. database records and thumbnails for them.
If you have enabled View > Metadata > Referenced in Photos, such files will show a tiny arrow on their thumbnails (or an exclamation mark if Photos cannot find them in the location recorded in the Photos database).
Since photos and videos are large files, you could reduce Mac and iCloud storage by using referenced files. However, support for these is fiddly in Photos, and iCloud and Time Machine ignores them — so just avoid them.
Shared Albums in Photos
Shared Albums are an easy way for family and friends to share and pool photos. Shared Albums are stored in iCloud but don’t count against your iCloud usage. However, they come with some caveats that you should be aware of (Read about these here).
Shared Albums’ details are stored in the Photos library, along with those of regular (user-created) albums, in ZGENERICALBUM and related tables.
How to Export Photos or Videos
Once you import photos into the managed world of Photos, you can do a lot of nice stuff like edit, make albums; create cards, calendars, slideshows, prints etc. — and Apple does lots of AI-driven smart things with them. But it also has downsides: You can’t find those photo with Finder. If you Optimize Mac Storage, Time Machine won’t back up the optimized photos. You can’t bulk export albums into regular folders while preserving the folder / album hierarchy and file formats. You can’t even export your Favorites album.
The Photos app does offer Export functionality as detailed here. It’ll export unmodified originals as well as edited photos, but with some limitations:
Avoid the shortcut of dragging and dropping to get photos out of the Photos library, as this will remove the metadata and reduce the image quality.
Exporting with Photos has many shortcomings, for example:
1) Your library might have photos in multiple formats, e.g. HEIC, JPG, PNG, RAW, TIFF etc., but Photos only offers three output formats — all photos will be converted to the one format you choose:
2) Want to export all albums? You’ll get one big folder — not a separate one for each album. You also can’t export the entire Photos library into folders by year — it can only be done one year at a time.
3 ) If you export the Favorites album (all your best photos), it’ll treat it as a collection of moments, and export them all separately — not one folder.
A good option to bulk-export photos and videos into folders by year, album and moment is Photos Takeout app [website][Mac App Store page]. It works with all macOS versions from Sierra up to Sequoia. It exports local, iCloud based as well as referenced files. It preserves folder structure, metadata and image resolution. It also exports Favorites and Shared Albums.
Apple Photos offers an intuitive, integrated way to aggregate, organize and enjoy your photos, but it keeps your assets in a rather opaque way. We hope our short tour has demystified much of how Photos works. If you still have any unanswered questions, please leave a comment below.
While you’re here…
Check out JOGGLE, our new, free, mildly cerebral word game. Thousands of one-minute brain-twisters for novice, intermediate as well as accomplished cruciverbalists. Read about it here.