Manual EXIF data for manual lens

Started by jv471, February 25, 2016, 08:28:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.



I am new in the forum and i would like to post my request though i think someone already asked for something similar along time ago.

I am a huge fan of old manual lenses but as you know, the don't have any kind of electronics inside them, therefore there is a lack of information in the EXIF data of the photos(i.e.: diaphragm aperture, lens brand,.... ).

So, since it's possible to set the camera aperture and shutter speed from the ML menu, i would like to know if it is possible to add a feature that allows to manually enter the aperture value in the menu (just like with a modern lens) and write that value into the EXIF data when the picture is taken.

I've been trying to figure it out by myself but, despite of searching on the forum, i couldn't find a good tutorial that explains how to create a script or module from scratch.


Here's a Lua script that does basically what you want. The metadata is saved in a sidecar file (trying to overwrite the CR2 is dangerous).

--writes custom metadata to an xmp sidecar file


xmp_template = [[
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c011 79.156380, 2014/05/21-23:38:37        ">
<rdf:RDF xmlns:rdf="">
  <rdf:Description rdf:about=""


function get_sidecar_filename()
    return string.format("DCIM/%03dCANON/%s%04d.XMP", dryos.shooting_card.folder_number, dryos.prefix, dryos.shooting_card.file_number)

function write_xmp(fnumber, fl, lens)
    local f =, "w+")

function property.GUI_STATE:handler(value)
    if value == GUISTATE_QR then
        write_xmp(meta_menu.submenu.Aperture.value, meta_menu.submenu["Focal Length"].value,"MANUAL LENS")

meta_menu =
    parent = "Shoot",
    name = "Metadata",
    help = "Custom metadata for non-chipped lenses",
    submenu =
            name = "Aperture",
            help = "Manually enter the Aperture",
            min = 10,
            max = 280,
            value = 40,
            update = function(self)
                return string.format("f/%d.%d", self.value // 10, self.value % 10)
            name = "Focal Length",
            help = "Manually enter the Focal Length",
            min = 10,
            max = 300,
            value = 50,


NOTE: I found a bug in the config.lua library. So the submenu values aren't loaded correctly. Here's a diff to fix the issue

diff --git a/scripts/lib/config.lua b/scripts/lib/config.lua
--- a/scripts/lib/config.lua
+++ b/scripts/lib/config.lua
@@ -74,7 +74,7 @@
     if m.submenu ~= nil then
         --todo: recurse into sub-submenus
         for k,v in pairs(m.submenu) do
-             v.value =[]
+             v.value =[k]
     return cfg


That's perfect!

I am going to try it and i'll let you know if it worked.

Thank you so much.


Hello again!

I am trying to use the script, but it seems i am abit useless and can't make it work.

I've downloaded the latest ML nightly build, installed it and copied the file with the script into the script directory but but i don't know how to run a LUA script.  I couldn't neither found de config.lua file you are talking about.

Help, please!


Load the Lua module ( in the modules tab, then restart the camera and look in the Shoot > Metadata menu

config.lua is in ML/scripts/lib


There is no LUA module in the modules tab and there is no "lib" directory under "scripts".

I installed the lates nightly build for my camera (600D) wich, according to should be natively supported ("merged") but can't find the module  :'(



Sh*t. Didn't know that.

I guess i'll have to wait until i get a better camera.

thank you anyway for your quick responses and your effort.  :)