Inside and Out of Photos for Mac

From Photos 3 (High Sierra) to Photos 9 (Sonoma)

Rotten Apple
10 min readJan 26, 2021

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. Accessing the photos directly or getting them out of Photos 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 extract your best photos of the past 10 years for making yearbooks.
  • To make your neatly curated 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. “ICPL” for short
  • 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 Photos for Mac, 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. Afterwards, we’ll look at the ICPL and referenced files.

The Photos Library

Apple Photos library for Mac icon in Pictures folder
The Photos Library — Usually found in the Pictures folder

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 — 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.

Unlock the secrets of your Mac Photos library

A word of caution: Don’t modify, move or delete any of the Photos library package’s contents, as this may corrupt the library and render it unusable.

The Folder Structure

Show Package Contents vary a bit depending on whether you have Photos 9 (Sonoma), 8 (Ventura), 7 (Monterey), 6 (Big Sur), 5 (Catalina) or 4 (Mojave):

Mac Photos library file structure in macOS Catalina, Big Sur and Mojave
Left: Photos library contents in macOS Catalina and later. Right: In Mojave and earlier.

Photos for Catalina and later stores unedited originals of photos and videos in the Originals folder, in sub-folders named 0–9 and A-F. However, their file names e.g. IMG_237.jpg and titles that you may have added are replaced by “GUID” names like C77F6C93–398B-4363–8254–6DC90834D2E.heic. GUID stands for “globally unique identifier”, and Photos uses it to keep track of each photo and all its manifestations.

In Mojave and earlier, the unedited original files reside in the Masters folder. The structure of the Masters folder is more human-friendly than Originals in Catalina and later — you’ll find one folder for each year, e.g. 2014, 2015 etc.; and within each year are sub-folders for every month for which photos exist, e.g. 01 for January, 02 for February etc.

Mac Photos originals and masters folders and subfolders
Left: Sub-folders of Originals in Catalina and later. Right: Sub-folders of Masters in Mojave and earlier.

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 houses SQL (Structured Query Language) databases that govern everything in Photos. The contents of these databases differ in every version of Photos, especially since Mojave. This is why you can’t open a Monterey library on a Mac running Big Sur Mac, 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, Masks, Plugins etc. are for internal purposes and of little interest to most of us.

Photos for Monterey has an extra folder named Scopes. Its contents:

Photos for Monterey, Scopes folder for shared folders
‘Scopes’ folder in Monterey. Not of much interest to lay explorers.

Edited Photos, Albums and Special Types

Well, we found our unedited photos, but where are the edited photos saved? The short answer: Nowhere. They are generated on the fly, when needed. This is more efficient than storing both original and edited versions. 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 or defaults that you have chosen. The edited version isn’t created when you view a photo — what you see is its JPG version incorporating the latest edits, which Photos stores in the Resources folder.

Albums are also generated only when you open them. Photos stores albums’ 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 other albums to which it belongs. However, 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:

Photos for Mac database contents
Contents of the Photos databases for Big Sur, Catalina and High Sierra

The databases in Photos for Monterey and Ventura are mostly like Big Sur, with a few tables renamed and added. The changes from Ventura to Sonoma mostly relate to Apple Photos’ AI and face/pet recognition features. The important tables and their contents are as follows:

ZASSET (Big Sur and newer), ZGENERICASSET (Catalina) and RKMASTER (Mojave and older) contain one record for each photo and video. The record identifies the photo or video’s file name, title, size, storage location, file path; whether edited, favorite, grouped, from 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 (Catalina and newer) stores information about the photo or video’s orientation, time zone, original file size, original dimensions, view count, whether it’s been deleted or shared, and pointers to information that is stored in other tables.

ZCOMPUTEDASSETATTRIBUTES (Catalina and newer) is where Photo app’s algorithm “grades” your photos on factors such as harmonious colors, interesting subject, pleasant camera tilt, composition, lighting, noise, perspective, symmetry, sharp focus, tastefully blurred, well framed subject, well timed shot etc. These drive Photos’ machine learning-powered features like Memories, Days, and For You. Learn more here.

ZEXTENDEDATTRIBUTES (Catalina and newer) 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.

The 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 Ventura, they are further incremented.

ZPERSON, ZDETECTEDFACE, ZDETECTEDFACEGROUP are some of the tables that store face recognition data.

All the great features that you enjoy in Apple Photos are powered by the above data. From arranging photos, creating albums, non-destructive editing, face recognition, image search, syncing via iCloud across all devices — everything is a combination of the original unmodified photos and this data.

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 the iCloud Photos Library (ICPL), photos from all connected Apple devices — your Mac, iPhone and iPad — are stored in the ICPL and can be accessed on 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 ICPL, full resolution original photos are normally saved in the Photos library as well as ICPL — even if you’ve opted for ‘Optimize storage’ in Photos Preferences. Only when the Mac’s disk is getting full, Photos will ask whether to manage storage, and then keep lower resolution images on the Mac, and full sized photos in ICPL.
  • Uploaded from other devices: By default, full resolution original photos stay in ICPL and syncing saves their thumbnails and JPG copies in the Mac Photos library. On clicking their thumbnails in Mac Photos, the full sized photos are downloaded — at which point the ICPL as well as the Photos library have full resolution photos.

You can view, delete, share and download photos directly from your ICPL as explained in this tutorial.

How to see photos stored in iCloud Photos Library (ICPL)
If you have enabled ICPL, go to www.icloud.com, log in and click on the Photos icon to find your photos.

Referenced Files

These are photos and videos stored outside the library, e.g. on an external HD. The Photos library only records “references” to them. To create referenced files, uncheck ‘Copy items to Photos library’ in Photos Preferences, then drag the items into Photos. The full-size original files will stay on the EHD, and references i.e. database records and thumbnails generated.

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).

Referenced files in Photos for Mac: Icons broken missing links
Referenced files when viewed in Photos (Enlargement)

Since photos and videos take up a lot of disk space, you could use referenced files to manage storage on your Mac. However, support for referenced files is fiddly in Photos and non-existent in iCloud — and even Apple admits this.

You can find the original unmodified referenced files in their original location, i.e. external drive or a folder on your Mac. However, Photos handles edits to these in the same way as for “local” files, i.e. editing instructions are stored in the Photos database, and edited versions of the images created on demand.

How to Export Photos or Videos

For straightforward exports, use Photos app’s functionality as detailed here. It’ll export unmodified originals as well as edited photos with some options.

Photos for Mac: File Export Unmodified Original or Edited metadata
Photos offers these export options. Use smart albums to further refine selection.

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 limitations, e.g. no good way to export albums (If you export multiple 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.

To bulk-export photos and videos into folders by year, album and moment, a good option is Photos Takeout [website][Mac App Store page]. This program works on all macOS’s from Sierra up to Sonoma. It exports local, ICPL-based as well as referenced files, keeping folder structure and metadata intact.

Photos Takeout app exports Mac Photos library albums and years asfolders
Photos Takeout app for Mac — To bulk export Year-wise and Album-wise folders

Apple Photos offers an intuitive, integrated way to aggregate, organize and enjoy your photos, but it keeps your assets in a rather opaque way. Hopefully our short tour has demystified some aspects of how Photos works. If we have missed out anything important, or if you 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.

Joggle — Select from three levels of difficulty: FUN, WIZ and PRO

--

--