• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ExifTool from within the script. The definition of the lens.

Participant ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

I Use LensTagger. But sometimes you need to rewrite the lens in several ways.
Creating the "newlens" tag as an enum. It contains a list of lenses. Creating a function. I seem to be correctly escaping problematic characters.

 

function f.ExifTool(data, path)
	local exiftool = 'c:\\Users\\ADrobkov\\AppData\\Roaming\\Adobe\\Lightroom\\Software\\exiftool.exe'
	local command = exiftool .. ' ' .. '"' .. data .. '" "' .. path .. '"'
	Debug.pauseIfAsked('------------')
	local handle = io.popen(command)
	local result = handle:read("*a")
	handle:close()
end

 

In the script

 

if target.newlens == 'Samyang_35' then
data = '-Lens="Samyang 1.4/35mm MF" -LensSerialNumber="F317A0005" -LensModel="Samyang 1.4/35mm MF" -LensType="Samyang MF 35mm f/1.4 AS Sony E" -MaxApertureValue="3.5" -FocalLengthIn35mmFormat="35" -m -overwrite_original_in_place -P'
end
Debug.pauseIfAsked('set_lens')
f.ExifTool(data, target.path)

 

All data for forming "data" was taken from LensTagger. I start, the script is executed, I read the data, only the lens changes to "Samyang", everything that is ignored after it. Although the "-overwrite_original_in_place " parameter is specified, arw_original is still created.
I can't figure out what I'm missing?

TOPICS
SDK , Windows

Views

370

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 14, 2020 Jul 14, 2020

Also, I've avoided using io.popen(). At least on Mac, there's no way to get the exit code of the process, which is important for robust error handling (e.g. when the shell can't execute the command).  I use LrTasks.execute(), which provides the exit code but is less convenient to use. I've got a utility function I use to make it easier:

 

--[[----------------------------------------------------------------------------
public int exitCode, string output, string errOutput
safeExecute (string comma
...

Votes

Translate

Translate
LEGEND ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

[This post contains embedded images that don't appear in email. View the post in your Web browser to see the images.]

 

I set a breakpoint and examined the value of "command":

johnrellis_0-1594746779899.png

 

Too much quoting and escaping to see what's going on. So I dumped its contents to "debug.log":

johnrellis_1-1594746869111.png

and then clicked the Log button at the bottom to open "debug.log" in my text editor. Now it's easier to see one thing that's going wrong:

20/07/14 10:15:17 com.johnrellis.debuggingtoolkit	TRACE	c:\Users\ADrobkov\AppData\Roaming\Adobe\Lightroom\Software\exiftool.exe "-Lens="Samyang 1.4/35mm MF" -LensSerialNumber="F317A0005" -LensModel="Samyang 1.4/35mm MF" -LensType="Samyang MF 35mm f/1.4 AS Sony E" -MaxApertureValue="3.5" -FocalLengthIn35mmFormat="35" -m -overwrite_original_in_place -P" "/Users/john/Desktop/test pics/dji/DJI_0830-1.jpg"

 

There's an extra set of quotes starting befre -Lens and ending at -P.

 

[Use the blue reply button under the first post to ensure replies sort properly.]

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

Also, I've avoided using io.popen(). At least on Mac, there's no way to get the exit code of the process, which is important for robust error handling (e.g. when the shell can't execute the command).  I use LrTasks.execute(), which provides the exit code but is less convenient to use. I've got a utility function I use to make it easier:

 

--[[----------------------------------------------------------------------------
public int exitCode, string output, string errOutput
safeExecute (string commandLine [, boolean getOutput])

Executes the command line "commandLine"in the platform shell via
LrTasks.execute, working around a bug in execute() on Windows where quoted
program names aren't accepted.

If "getOutput" is true, "output" will contain standard out and standard
error and "errOutput" will be "".  If "getOutput" is "separate", then
"output" will contain standard out and "errOutput" will contain standard
error.  If "getOutput" is false, then both "output" and "errOutput" will be
"".

Returns in "exitCode" the exit code of the command line. If any errors
occur in safeExecute itself, "exitCode" will be -1, and "output" and
"errOutput" will be:

getOuptut == "separate": "", <error message>
otherwise:               <error message>, ""
------------------------------------------------------------------------------]]

function Util.safeExecute (commandLine, getOutput)
return Debug.callWithContext ("", function (context) 
    local outFile, errFile

    context:addCleanupHandler (function ()
        if outFile then LrFileUtils.delete (outFile) end
        if errFile then LrFileUtils.delete (errFile) end
        end)
        
    if getOutput then 
        local uuid = LrUUID.generateUUID ()
        outFile = child (getStandardFilePath ("temp"), uuid .. ".out")
        commandLine = commandLine .. ' > "' .. outFile .. '"'

        if getOutput == "separate" then
            errFile = child (getStandardFilePath ("temp"), uuid .. ".err")
            commandLine = commandLine .. ' 2>"' .. errFile .. '"'
        else
            commandLine = commandLine .. ' 2>&1'
            end
        end

    if WIN_ENV then commandLine = '"' .. commandLine .. '"' end
    local exitStatus = LrTasks.execute (commandLine)

    local output, errOutput, success = "", ""

    local function outputErr (file, output)
        local err = string.format ("Couldn't read output:\n%s\n%s", 
            file, output)
        if getOutput == "separate" then 
            return -1, "", err
        else
            return -1, err, ""
            end
        end

    if outFile then
        success, output = pcall (LrFileUtils.readFile, outFile)
        if not success then return outputErr (outFile, output) end
        end
    if errFile then
        success, errOutput = pcall (LrFileUtils.readFile, errFile)
        if not success then return outputErr (errFile, errOutput) end
        end

    return exitStatus, output, errOutput
    end) end
    

 [Use the blue reply button under the first post to ensure replies sort properly.]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Yes! LrTasks.execute () works! Thanks!
The only thing I noticed is that Serial Number is not set either through LensTagger. Strange, before this was installed LR 8.2 and it worked. I've tried every method. BUT I couldn't install it via exiftool. Although it is displayed correctly in old photos.
Can you check if it's just me?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

LATEST

"The only thing I noticed is that Serial Number is not set either through LensTagger. Strange, before this was installed LR 8.2 and it worked. I've tried every method. BUT I couldn't install it via exiftool. Although it is displayed correctly in old photos."

 

For future reference, this issue was raised separately in this thread: https://community.adobe.com/t5/lightroom-classic/lr-9-2-1-does-not-display-the-camera-s-serial-numbe...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines