The Mac’s Photos app can take up a lot of storage space—actually, it’s not the app itself that uses up space, but its database of images that you have imported into Photos. So naturally, when you need to free up storage space, one way to do that is to delete photos from the Photos app.

Say you deleted some photos in Photos, but now you need to get those photos back. And what if, after deleting those photos, you added some new ones. So now you want to restore the deleted photos, while at the same time, preserve the just added ones. Can it be done?

Yes, but it requires a little finesse. You will also need an external drive with enough storage to restore your entire Photos Library.

If you have been performing a Time Machine backup, that could help. Here’s the primary concern: Time Machine automatically deletes older snapshots as it adds new ones. Files that have been deleted from your Mac are only retained as long as the oldest snapshot that contained them.

Time Machine retains weekly snapshots until a drive becomes too full to keep the oldest ones. If you have a very large drive or haven’t performed any Time Machine updates in the months since you last had access to the drive, the old Photos Library’s state should be preserved.

Assuming that’s the case, we can proceed.

Apple treats the Photos Library (located in the Pictures folder) as an integral thing: it has a single icon and you interact with it like a file. However, it contains lots of pieces, including the original versions of every imported image and video, thumbnails, an organizational database, and files that represent modifications you’ve made to images. I typically recommend not mucking around inside that package unless you have a corrupted and unrecoverable Photos Library.

Time Machine lets you peer within the Photos Library to retrieve specific images, but I would suggest the best course of action with the highest chance of success is to retrieve the entire archived library. That requires enough storage space, of course, either on the startup volume, the Time Machine volume, or another external drive that can be plugged in at the same time as the Time Machine backup. You best bet is to use an external drive.