6 Replies Latest reply on Jun 21, 2017 11:43 PM by bernie west

    Problem writing exif to custom metadata field with catalog:withPrivateWriteAccessDo

    bernie west

      I'm writing a LR Plugin that accesses proprietary fuji exif using exiftool.  I have successfully read the metadata and saved it into appropriate variables.  I'm now trying to write it to the custom metadata fields my plugin has defined and created.  It's not working, though.  Here's the function to write the metadata.  It is called from within a LrTasks.startAsyncTask() function.

       

      ------- Write the relevant fuji exif to LR metadata -----------

      function writeMetadata(objCat, tblImagesExif)

        local arrPhotos = {}  --array to hold LR photo objects

       

        --get image list as an array of LR photo objects

        arrPhotos = objCat:getMultipleSelectedOrAllPhotos()

       

        str = objCat:withPrivateWriteAccessDo(

          function(context)

            for k,v in pairs(arrPhotos) do

              for i,image in pairs(tblImagesExif) do

                if image.filePath == v:getRawMetadata("path") then

                

                  if image.ISO ~= nil then

                    v:setPropertyForPlugin(_PLUGIN, "ISO", image.ISO)

                  end

                  if image.drMode ~= nil then

                    v:setPropertyForPlugin(_PLUGIN, "DR_Mode", image.drMode)

                  end

                  if image.dr ~= nil then

                    v:setPropertyForPlugin(_PLUGIN, "DR", image.dr)

                  end

                  if image.filmSim ~= nil then

                    v:setPropertyForPlugin(_PLUGIN, "FilmSimulation", image.filmSim)

                  end

                

                  break --break out of the for loop as a match has been found

                end --end if

              end --end for

            end --end for

          end --end function

        )

       

        LrDialogs.message(str)

      end

       

      Some notes - objCat and tblImagesExif are populated with the correct values, and objCat:getMultipleSelectedOrAllPhotos() returns a valid list of photos. I've put debugging break points in at

      str = objCat:withPrivateWriteAccessDo(

       

      and

       

      function(context)

       

      It stops at the first one twice (str=nil and then str="executed") and never stops at the second one.

       

      Any ideas?