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.

jv471

Hello.

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.

dmilligan

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

require("config")

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="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
   exif:ExifVersion="0230"
   exif:FNumber="%d/10"
   exif:FocalLength="%d/1"
   aux:Lens="%s">
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
]]

GUISTATE_QR = 3

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

function write_xmp(fnumber, fl, lens)
    local f = io.open(get_sidecar_filename(), "w+")
    f:write(string.format(xmp_template,fnumber,fl,lens))
    f:close()
end

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")
    end
end

meta_menu = menu.new
{
    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)
            end
        },
        {
            name = "Focal Length",
            help = "Manually enter the Focal Length",
            min = 10,
            max = 300,
            value = 50,
        }
    }
}

config.create_from_menu(meta_menu)


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 = cfg.data[m.name]
+             v.value = cfg.data[k]
         end
     end
     return cfg

jv471

That's perfect!

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

Thank you so much.

jv471

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!

dmilligan

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

config.lua is in ML/scripts/lib

jv471

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 http://www.magiclantern.fm/forum/index.php?topic=14828.0 should be natively supported ("merged") but can't find the module  :'(

dmilligan


jv471

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.  :)