Skip to content

Instantly share code, notes, and snippets.

@fbuchinger
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbuchinger/e5dd1acb3f4262ecf0d0 to your computer and use it in GitHub Desktop.
Save fbuchinger/e5dd1acb3f4262ecf0d0 to your computer and use it in GitHub Desktop.
mercurial imgtrack extension

Mercurial imgtrack extension

Programmers have been using version control systems for decades to record/log/merge/revert changes in their source code. Photographers don't have a similar tool, although they also have to wrangle with many different versions of one photo:

  1. a photo is typically shot in a Camera RAW format, a kind of digital negative, that needs automatic or manual processing to produce a visible image on the screen
  2. the edited Camera RAW photo has to be saved in another format (e.g. Photoshop PSD or JPEG), because RAW is basically a read-only format. Often multiple versions of one image are saved to test different effects and filters.
  3. then the edited photos are published on photosharing sites or online photo galleries. To increase the upload speed, optimized JPEG versions of the source files are created. The gallery software might create additional versions of the image (e.g. thumbnails and smaller previews).

The problem

This multifile-workflow brings a few problems:

  • photographers often need to find the source files for derived images (Which RAW file was the base for portrait01.jpg?)
  • the editing history of a photo gets lost, because the target file format doesn't support storing it (e.g. JPEG). For subsequent changes this editing history might be really important.
  • clients of photographers sometimes request changes for a photo. This often happens by email with pasted-in preview pictures, making it hard for the photographer to find the correct source photo, applying the changes and customer again. an issue-tracker like system could come in handy here

The solution

hg imgtrack is a mercurial-based solution to track relations between photos, their editing history and storage locations. It works similar to the Large Files extension and thus doesn't track the photos itself, but only their metadata and relations.

Use Cases

As a photographer, I want hg imgtrack to track derived/edited versions (e.g. downsized jpegs) of my source photos (e.g. RAW files) so that i can trace back an edited version to its source file. The tracking mechanism should support an arbitrary number of derived images with an arbitrary nesting depth (i.e. derived child-images, grand-child-images,...) that are not necessarily stored my system.

hg imgtrack should tell me that http://example.com/gallery/03.jpg is the uploaded version of patagonian_sunset03.jpg which itself is an edited version of the raw file P019278.NEF

As a photographer, I want hg imgtrack to record the edits that lead to producing the image (if it was derived from another image). Ideally, hg imgtrack should be able to reconstruct the image given its predecessor image and provided that the required Image Processing Tools are installed on the system (e.g. Photoshop, ImageMagick etc).

hg imgtrack should tell me that patagonian_sunset03.jpg is an 50%-downsized, sharpened version of P019278.NEF processed by ImageMagick 6.7

Example Workflow

This example assumes that ImageMagick is installed on the system, because it is wrapped in some hg imgtrack calls. Note: this is a first guess, workflow still needs to be refined.

First we initialize imgtrack in the photo directory and cd to it.

$ hg imgtrack init (photo-directory)

$ cd (photo-directory)

Now we convert the raw file P737438.NEF to a downsized jpeg version. This happens by wrapping the ImageMagick convert utility. By doing so, we can track the edit.

$ hg imgtrack convert P737438.NEF -resize '40%' target.jpg

The changes are recorded to the repository

$ hg imgtrack addremove

$ hg imgtrack commit -m "RAW downsize"

$ hg imgtrack diff

P737438.NEF -> ImageMagick 7.20 40% resize (additional opts..) -> target.jpg

Design

TBD, but probably similar to Large files Extension (see related work)

Open Questions

  • How can we implement a lightweight "visual" diff between the image versions (cf. github.com image diffs)

Related Work

Mercurial Large Files Extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment