Employing MongoDB for a photography website's client proofing section.

MongoDB, a document-oriented NoSQL database, offers a flexible and scalable platform helping store data for a variety of applications, making it a common tool to choose for storing certain types of data. This includes utilizing it for storing image metadata such as EXIF data and download information. In this article, I briefly explain how I used MongoDB for a client proofing area for a photography website.

What is a Client Proofing Area?

A client proofing area is a secured section of a photographer's website where clients can review, download, comment and approve photos. This area allows photographers to deliver their work to clients directly and enables clients to select their favorite photos, request edits, or download approved images.

Storing EXIF Data with MongoDB

EXIF (Exchangeable Image File Format) data is a standard that specifies the formats for images, sound, and other ancillary tags used by digital cameras and scanners. EXIF data includes information such as the camera model, exposure time, ISO speed, and more.

With MongoDB, you can store EXIF data along with other photo specific data, in JSON-like documents, which allows for quick access and manipulation. In my view, a perfect example how MongoDB can be used efficiently. Here's a simplified example of how you might structure a document:

{
"_id": {"$oid": "5e349915cebae490877d561d"},
"filename": "RHX00656.jpg",
"key": "photos/87a1730c-4a57-4b61-a0fa-937ea0b5a67a/rhx00656.jpg",
"exif": {
"Make": "RHX00656.jpg",
"Model": "ILCE-7RM4",
"Software": "Adobe Photoshop Lightroom Classic 11.5 (Macintosh)",
// more EXIF data
},
// more fields
}

Storing EXIF data in MongoDB allows for efficient retrieval of specific data. For example, you could use MongoDB's query language to find all images taken with a specific camera model or at a particular ISO speed.

Tracking Downloads

You can also use MongoDB to track the number of times a client downloads an image from the proofing area. A simple way to achieve this would be to add a 'downloads' field to your MongoDB documents:

{
"_id": {"$oid": "5e349915cebae490877d561e"},
"filename": "RHX00656.jpg",
"gallery_id": {"$oid": "64846722292c05a373717c6c"},
"downloads": [
{
"email": "user@domain.com",
"date": "2023-06-12T12:43:47.233+00:00"
},
{
"email": "user@domain.com",
"date": "2023-06-12T12:43:47.233+00:00"
},
],
// more fields
}

Whenever a client downloads an image, you could increment the 'downloads' field for that image using MongoDB's `$inc` operator.

Building the Client Proofing Area

When building the client proofing area, I've considered creating a user-friendly interface that allows clients to:

  • View images: Display images in a gallery view. Using MongoDB, you can quickly retrieve all images for a specific client or session.

  • Review EXIF data: Allow clients to view the EXIF data for each image, if desired. MongoDB's flexible schema makes it easy to retrieve this information.

  • Select favorites: Clients can select their favorite images. This selection could be stored in MongoDB, either as an array of image IDs in the client's document or as a 'favorites' field in each image document.

  • Request edits: Allow clients to request edits to images. These requests could be stored in MongoDB, tied to the specific image document.

  • Download images: As clients download their approved images, increment the download count in the database to keep track of the number of downloads.

MongoDB proved to be a powerful tool for helping to build a this client proofing area. Its flexibility and scalability make it well-suited for storing image metadata and tracking client interactions. However, like any tool, it is only as effective as the way it is utilized. Carefully considering the structure of your data and the needs of your users will ensure you create a proofing area that is robust and easy to use.