Scale bars

I recently wrote a Python script that reads EXIF data for camera, lens, and focus position and adds a scale bar to the photos:

Here's an example of the result:

How it works

It's written with prime lenses in mind, though other lenses could be adapted to work for it. I didn't attempt a general formula, with my limited understanding of optics. Additionally, most people online say focus distance is not reported accurately from EXIF data at all, so a general formula wouldn't probably work. Even with perfect EXIF data, I'm not sure a general solution is actually possible; real life lenses are complicated.

Instead I manually recorded pixels/mm at various focus distances with the camera, and interpolate between them linearly. (Therefore, it doesn't matter if the EXIF focus distance is actually accurate, just that it's internally consistent.) It's a crude solution but it does seem to work; with test photos of rulers at random focus distances it seems to be reasonably accurate.

Right now it only works with known combinations of lenses and cameras (really just the one I use most often now, my OM-5 with the M.Zuiko 60mm macro lens). It feels like a safe assumption to just go off sensor size for the camera, rather than rely on an individual model, but without more cameras and lenses to try out I'm not confident about any assumptions.

Making this useful for other people

I don't think a Python script is the best way to do this part. I want a sort of webpage that people can quickly add scale bars onto. The automatic derivation from EXIF data part will be hard to get support for without people contributing their own measurements (cameras are pretty expensive!); most likely I'll add an input field for manually specifying pixels/mm at various focus distances, and give people instructions on how to figure that out on their own.


  • Rotating the scale bar
  • Changing scale bar style (color)
  • Changing the unit (cm, mm, etc)
  • Non-macro or even telephoto distances (issues with focus distance inaccuracy might make this unreasonable: TBD)
  • Microscopes: supporting photos taken through a dissecting microscope eyepiece would probably also be useful; these focus by physically moving the microscope up and down, so they'd work a little different (you'd specify the zoom factor). The camera sensor size and resolution would be the only other factors in this situation. Light microscopes would work similarly. Neither are going to be as luxurious as the camera solution, as no information about the microscope would be in the EXIFs
  • Resizing: A limitation that might not be reasonable to work around is that you can't resize images before using this tool, as pixels/mm is the magic factor that'd be ruined by resizing (so cropping is ok). I'm not sure resizing is recorded in EXIF data; if it were, it'd be easy to adapt. If not then we're hosed!
Publicado el agosto 17, 2023 12:24 MAÑANA por wweellll wweellll


Fotos / Sonidos




Agosto 12, 2023 a las 09:30 MAÑANA PDT


No hay comentarios todavía.

Agregar un comentario

Acceder o Crear una cuenta para agregar comentarios.