Recovering magnification (real image size) from lens metadata

  • 1
  • Idea
  • Updated 12 months ago
  • (Edited)
Todd Shaner encouraged me to make this (somewhat lengthy) post regarding how to use metadata to recover the scale of a photo in the (stupid, but likely) case that you forgot to write down the scale in your notebook when you took the photo. In his reply to this post, Todd links to some previous discussions of this subject.

I have taken thousands of photos with a Canon 65mm 1x - 5x lens and 5D Mark III body, and did not write down the magnification of most of these photos, and now I need it. So I looked at the metadata "DOF" (Depth of Field), which is reported by Exiftool.

It turns out that DOF is a "Composite Tag" which means it is calculated by ExifTool from other metadata that are actually in the photo. But it is convenient because it is a single string that gives all the available information in the photo about the subject-camera distance. Because it is a Composite Tag, we need to give Lightroom a copy that it can access. I decided to copy DOF to the Event field, because I don't use that field for anything else. For raw files, the following command will copy DOF from raw files to the Event field in the corresponding xmp sidecar files in a folder:
$ exiftool -overwrite_original_in_place -tagsFromFile %f.CR2 "-event<dof" *.xmp
After reading the metadata from these files, I used Jeffrey's Data Explorer plugin to determine that I had 25 unique values of this string for photos taken at 3 aperture values: f/13, f/14, and f/16, which gave me hope that I could recover the scale of the photos.

I then took two series of photos with this lens, at each of the above aperture values, at magnifications from 1x to 5x in steps of 0.25 (1.00 : 1, 1.25 : 1, etc.). Because I did it twice, small errors slipped in, so I sometimes got different values for the same magnification, because the lens wasn't extended exactly the same amount.

The results of this are in this table

I have color-coded the entries to indicate various issues. The gray data are the same as the adjacent values, meaning that, for instance, magnification of 4.75 : 1 can't be distinguished from 4.5 : 1. Also, presumably due to small differences how I set the lens, I got two different values for the magnifications of 2.50 : 1 and 1.75 : 1.

But the real stumbling block to this approach is that values of 1.25 : 1 & 1.75 : 1 and 1.00 : 1 & 2.00 : 1 are (respectively) identical (teal and magenta text). When you use this lens, as you increase magnification, you first focus closer, from 1x to 1.5x, and then move away from the subject from 1.5x to 5x, and this is reflected in the values above.

So, in summary, you can use the DOF metadata to reliably (if, sometimes, approximately) recover the magnification for all magnifications except 1x, 1.25x, 1.75x and 2x.

It turned out for my project that nearly all my photos were 1x or 2x, which was very annoying. But then I noted that my photos were taken under (approximately) controlled lighting conditions, and since 2x needs 1.33 stops more light, I was able to use other data to distinguish these photos. (Also, the image size varied, when I could remember the actual size of the object photographed).

Note, finally, that I don't think that this "Depth of Field" has any relation to my perceived depth of field. Depth of field in my photos seems to be seldom over 1 mm, not 7 – 18 mm as indicated by these values.

I hope this helps others who run into the same problem that I did.
Photo of Alan Harper

Alan Harper

  • 424 Posts
  • 84 Reply Likes

Posted 12 months ago

  • 1
Photo of Todd Shaner

Todd Shaner, Champion

  • 1066 Posts
  • 343 Reply Likes
Alan, I did a quick Google search on 'Canon 65mm macro makernotes' and apparently there is an entry for Magnification titled MacroMagnifiation:

https://www.davidkennardphotography.com/blog/245-how-to-calculate-subject-size-from-a-macro-photo.xh...

Is it showing in your CR2 files shot with the Canon 65mm 1x - 5x lens?
Photo of Alan Harper

Alan Harper

  • 424 Posts
  • 84 Reply Likes
Well, I certainly feel a fool. That solves my problem completely. And it is recorded to 0.1 x. Wow -- never underestimate the power of a well-constructed Google search!

Thank you, Todd
Photo of Todd Shaner

Todd Shaner, Champion

  • 1066 Posts
  • 343 Reply Likes
The Canon 65mm 1x - 5x macro is an esoteric lens with very little actual user information available on the Web. it's apparently the only Canon macro lens that actually records magnification in the MakerNotes. Had you not created this post I wouldn't have looked further.....and we'd both be fools. Glad to help!
Photo of Alan Harper

Alan Harper

  • 424 Posts
  • 84 Reply Likes
It turns out that the magnification reported does not line up exactly with the magnification I show in some test images (images of a ruler), but I think one can muddle it out and be pretty close. (Haven't investigated this closely yet).
Photo of Todd Shaner

Todd Shaner, Champion

  • 1066 Posts
  • 343 Reply Likes
How did you determine that and using what camera model? The Canon 5D MKIII Camera is 24mm x 36mm, but other models may deviate slightly from the full-frame and APS-C standard. At the link I provided there is an example using PS to make actual image measurements using the MacroMagnification value. Here's an example for an image with a 2.0x MacroMagnification value shot with the full-frame 5D MKIII. Does this correlate closer to the MacroMagnification value?

NOTE: This measurement applies only to subjects (i.e. ruler) that are placed exactly on the focus plane. If further away or closer the readings will be smaller or larger, respectively.

5D MKIII Sensor Width (36mm) ÷MacroMagnification (2.0x) = 18mm



(Edited)
Photo of Alan Harper

Alan Harper

  • 424 Posts
  • 84 Reply Likes
So, I did a bunch of photos of a ruler (both inches and mm) with my Canon 65mm 1x-5x + Canon 5D Mk III. The rulers were transparent and incised on the bottom. I tried my best to ratchet the lens to magnifications of 1.0x, 1.25x, etc. to 5.0x. (There are things I could do to be more accurate, but I figured the photos of the ruler would give me accurate magnification). I then moved the camera on a focusing rail until the ticks on the ruler were in focus (at wide open). I did this twice (ratchet lens to the various nominal magnifications then focus using the rail), so that I could see the effects of small differences in nominal scale on the lens (user error).

I then recovered the Macromagnification (call it "MM") field in these photos and put it in the Event field so I could classify the photos.

Right now, what I find is:

MM = 1.0x, scale on the lens is 1 : 1
MM = 1.4x, scale on the lens is 1.25 : 1 (no photos recorded 1.1x, 1.2x or 1.3x)
MM = 1.5x, scale on the lens is 1.5 and 1.75 (some of the photos at 1.75)
MM = 1.8x, scale on the lens is 1.75 (the rest of the photos at 1.75)

It continues like this, with the most egregious being

MM = 3.7x, includes all photos with scale on the lens of 3.5 : 1 and 3.75 : 1
MM = 4.8x, includes all photos with scale on the lens of 4.5 : 1 and 4.75 : 1

The most likely explanation for this is that while the data is reported ± 0.1, in fact ranges of magnifications are "binned" so that a range of magnifications are all reported with the same value, and many values in the range of 1.0x to 5.0x are not actually ever reported. In fact, I have taken 2000+ photos with this lens and only 14 of a possible 41 values for macromagnification are reported in these photos, which is further support for the idea that the lens "bins" values.

It would take more patience than I have to explore this fully. I do plan to measure the photos of rulers in Photoshop, so that I can confirm that the scale on the lens is accurate, and then I'll use the reported magnification as a best guess of the real magnification, even with the binning.
Photo of Todd Shaner

Todd Shaner, Champion

  • 1066 Posts
  • 343 Reply Likes
Whether that's normal behavior or an issue with the lens is anybody's guess. You might try contacting the author of the test I linked to concerning 'Calculating Subject Size.' There's a 'Contact' link at the below page. You can compare his and your macromagnification readings.

https://www.davidkennardphotography.com/blog/245-how-to-calculate-subject-size-from-a-macro-photo.xh...

You could also ask Canon Technical Support:

https://www.usa.canon.com/internet/portal/us/home/support/email
Photo of Alan Harper

Alan Harper

  • 424 Posts
  • 84 Reply Likes
So, I finally compared the observed magnification (width of sensor ÷ width of ruler shown) with the "nominal" magnification shown on the barrel of the lens and with the macromagnification data recorded in the photo. (Note that the sensor on a Canon 5D Mk III is about 103% of the standard 24 x 36 mm of 35 mm film).

What I found was that there were errors everywhere (including my measure of magnification, because I had to estimate the ruler to ± 0.1 mm), but that, in general, the macromagnification was usually within 5% of the observed magnification, while the indicator on the barrel of the lens was often less accurate. It would be useful to repeat this test with a ruler inscribed to tenths of millimeters, but I don't have one of those.
Photo of Todd Shaner

Todd Shaner, Champion

  • 1066 Posts
  • 343 Reply Likes
What I found was that there were errors everywhere (including my measure of magnification, because I had to estimate the ruler to ± 0.1 mm), but that, in general, the macromagnification was usually within 5% of the observed magnification, while the indicator on the barrel of the lens was often less accurate.
Lens manufacturing tolerances concerning lens focal length and all other parameters affected by it are no better than 5%. The lens barrel markings probably have at least an additional 5% manufacturing tolerance. So overall you could easily see a ±10% error between the MacroMagnification metadata reading and the barrel reading. This doesn't even include errors due to the "missing" MacroMagnidication readings you observed:

"In fact, I have taken 2000+ photos with this lens and only 14 of a possible 41 values for macromagnification are reported in these photos, which is further support for the idea that the lens "bins" values."

To get a more accurate reading for future shots only use one (1) barrel setting for each of the observed 14 bin values. Then calculate what the actual MacroMagnification is for each of these 14 bin values. Then the only error will be due to the accuracy of setting the barrel to those 14 values. Since there are only five marks (1X-5X) on the lens I don't see how you'll get good repeatability for more than those five settings. You could paint additional marks on the lens for the in-between settings.....but then you'll have a laboratory instrument...if that what you're trying to do.