Skip to main content
johnrellis
Legend
June 16, 2013
Question

LR 5 functions, methods, and properties not in LR 4 docs

  • June 16, 2013
  • 8 replies
  • 10896 views

While we're waiting for the SDK docs, I scanned for functions, methods, and properties not documented in the LR 4 SDK.  Here's what I found:

LrCatalog

Methods:

assertHasReadAccess

buildSmartPreviews (array of LrPhoto)

createPublishService

createVirtualCopies

getPhotoByLocalId

withReadAccessDo

Properties:

allPhotos

hasCatalogAccess

hasReadAccess

hasWriteAccess

path

targetPhoto

targetPhotos

LrCollection

Methods:

getSearchDescription

LrController

nextPhoto

previousPhoto

showBezel

showGrid

showLoupe

startSlideshow

stopSlideshow

triggerCapture

LrDialogs

closeFloatingDialogsForPlugin

presentFloatingDialog

presentWebViewDialog

showBezel (string message, [number fadeDelay])

showStringsDialog

LrDigest

HMAC

MD4

MD5

SHA1

SHA256

SHA384

SHA512

LrLogger

Methods:

configure

restoreConfiguration

saveConfiguration

wrapMethodWithTrace

wrapMethodsWithTrace

Properties:

_actions

_name

_savedConfigurations

will_debug

will_error

will_info

will_trace

will_warn

LrPhoto

Methods:

applyDevelopSnapshot

buildSmartPreview

deleteDevelopSnapshot

deleteSmartPreview

getDevelopSnapshots

locationIsPrivate

readMetadata

requestJpegThumbnail

saveMetadata

withSettingsForPluginDo

Properties:

countStackInFolderMembers

countVirtualCopies

isInStackInFolder

isVirtualCopy

localIdentifier

masterPhoto

path

stackInFolderIsCollapsed

stackInFolderMembers

stackPositionInFolder

uuid

virtualCopies

LrPhotoPictureView

makePhotoPictureView

LrPlugin

nativeFunction

LrPublishService

delete

getAllRemoteIds

promptEditDialog

LrPublishedCollection

Methods:

getSearchDescription

publishSelected

setSearchDescription

LrPublishedCollectionSet

Methods:

delete

LrPublishedPhoto

Methods:

getDevelopSettingsDigest

getMetadataDigest

LrTableUtils

debugDumpTable

LrUUID

generateUUID

LrView

Methods:

path_control

square_button

LrXml

xmlElementToSimpleTable

I didn't examine the classes LrExportContext, LrExportRendition, LrExportSession, LrExportSettings, LrFilterContext, LrVideoExportPreset, LrWebViewFactory.

8 replies

June 25, 2014

Hi,

I was trying to get HMAC working for my Lightroom plugin but there was no luck

I coould not find any reference to HMAC functions.

There is only MD5 which is given is SDK

local LrMD5 = import 'LrMD5' -- assign namespace to local variable

local digest = LrMD5.digest( 'some string' ) -- call "digest()" function in namespace

http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshoplightroom/pdfs/lr5/lightroom-sdk-guide.pdf

Does anybody know how to use the HMAC functions?

Thanks

johnrellis
Legend
June 26, 2014

A little poking around suggests how to use LrDigest:

d = LrDigest.SHA256.digest ("Hello world")

d => "64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c"

x = LrDigest.SHA256.init ()

x:update ("Hello ")

x:update ("world")

d = x:digest ()

d => "64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c"

June 26, 2014

Hi john,

I really appreciate the quick response and I have been struggling with this for a few days. Your example above works perfectly.

This is what I did

local sha = import 'LrDigest'

d = sha.SHA256.digest ("Hello world")

My requirement is to do HMAC

if you do this in PHP you do like this

$genarated_hmac = hash_hmac("sha256",'string input','private key');

I tried this in my Lua plugin file but it crashed the plugin

This is what I did

local sha = import 'LrDigest'

d2 = sha.HMAC.digest ('SHA256', 'test1','test2')

I was shooting in the dark as there was no reference I could use.

Please help me if you can.

Thanks heaps again

areohbee
Legend
December 21, 2013

Just noticed these methods never made it into SDK 5 doc:

* photo:saveMetadata

* photo:readMetadata

Subject to certain caveats, these methods do seem to work, and I'm using them in released plugins.

Anybody else have any experience/problems with them?

Thanks,

Rob

areohbee
Legend
December 4, 2013

photo:deleteDevelopSnapshot - used to work, but doesn't anymore (granted, it was never documented).

To be clear: @Lr5.3RC, the function still exists, executes, and says it worked, but no snapshots are actually deleted.

In original Lr5 version(s), beta and 5.0 anyway, the function worked, if Lr in develop module (not library module).

areohbee
Legend
November 26, 2014

Differences in master vs. virtual copy, snapshot-wise:

local masterPhoto = virtualCopy:getRawMetadata( 'masterPhoto' )

local snaps = masterPhoto:getDevelopSnapshots() -- gets master and virtual copy snapshots

virtualCopy:getDevelopSnapshots() -- NEVER works.

virtualCopy:deleteDevelopSnapshot( snap[1].id_global ) -- NEVER works.

masterPhoto:deleteDevelopSnapshot( snap[1].id_global ) -- always works in develop module (do not use snapshotID, which only sometimes works).

virtualCopy:createDevelopSnapshot( name ) -- works in develop module, but always creates a new snapshot (even if name already exists).

virtualCopy:createDevelopSnapshot( name, true ) -- ditto, so pre-delete in separate with-do func to re-create/update.

~R.

areohbee
Legend
August 24, 2013

Anybody have a clue about 'showStringsDialog'?

johnrellis
Legend
August 24, 2013

It appears to display a dialog with a scrollable list of strings:

LrFunctionContext.callWithContext ("test", function (context)

    LrDialogs.showStringsDialog {

        title = "Test Strings Dialog",

        strings = {"line 1", "line 2", "line 3"},

        cancelVerb = "Stop!"}

    end)

May be unfinished (and thus undocumented) -- the "title" and "cancelVerb" parameters are ignored.

areohbee
Legend
August 25, 2013

Thanks John.

It would be great if it was possible to have different fonts etc. for different strings.

I mean, in the simplest case, one can accomplish the same thing (pretty much) via a scrolled_view of a static_text view.

R

areohbee
Legend
June 30, 2013

Any idea what LrPlugin/nativeFunction might be?

johnrellis
Legend
July 1, 2013

Any idea what LrPlugin/nativeFunction might be?

A SWAG: It could be a way for a plugin to load and access native code, e.g.

myServerFunction = _PLUGIN:nativeFunction ("myServerFunction", "myserver.dll")

areohbee
Legend
July 1, 2013

That would open some doors .

~R.

areohbee
Legend
June 18, 2013

WARNING: photo:saveMetadata() returns *before* metadata has been saved, so if subsequent activity depends on completion (e.g. reading or locking xmp sidecar file), you still have to have some ad-hoc code to ascertain... I suspect same is true of readMetadata method.

areohbee
Legend
June 18, 2013

LrDialogs.closeFloatingDialogsForPlugin( _PLUGIN ) -- make sure you pass the plugin object (ID might work too, but I didn't try it).

Anybody know how to tell if user has closed a floater? I can tell in Lr4 because the function context get's cleaned up, however the function context is being cleaned up immediately in Lr5, which is why I spin and wait for an explicit close button (not the frame's 'X') in Lr5 case - not ideal. Here's the code:

self.open = true

if app:lrVersion() <= 4 then -- 4 (3 not supported)

    LrDialogs.presentFloatingDialog {

        title = title,

        save_frame = app:getAppName(),

        background_color = LrColor( unpack( bgColor ) ),

        contents = vf:column( vi ),

    }

    -- Lr4 does not close context until dialog closed.

else -- 5+

    LrDialogs.presentFloatingDialog( _PLUGIN, {

        title = title,

        save_frame = app:getAppName(),

        resizable = true, -- potential exists to need this in Lr4 too? ###1.

        background_color = LrColor( unpack( bgColor ) ),

        contents = vf:column( vi ),

    } )

    -- sleep until shutdown *or* quit button pressed.

    app:sleepUnlessShutdown( math.huge, 1, function()

        return not self.open -- quit once open flag is set false (self.open set to false when "Quit" button is clicked).

        -- upon return of true value, app will discontinue sleeping and control will proceed to clos the floater(s).

    end ) -- sleep forever if Lr5 (Lr4 does not close context until dialog closed). one second coarse interval.

    -- ###1 I need to figure out how to determine when dialog box has been closed.

    LrDialogs.closeFloatingDialogsForPlugin( _PLUGIN )

end

johnrellis
Legend
June 16, 2013

...and more:

LrRemoteCommunication

closeNamedConnection

launchApplicationWithPath

pollForMessage

sendMessageToServer

spawnTaskAndConnect

Inspiring
June 16, 2013

I've experimented a little with LrPhoto:getDevelopSnapshots() and applyDevelopSnapshot()

getDevelopSnapshots return indexed array with tables containing id_global, snapshotID and name string fields. snapshotID is then used as parameter for applyDevelopSnapshot().

Seems to be working ok, I'm going to use it in my The Fader plugin (actually its already implemented in  http://capturemonkey.com/beta/thefader_r799.zip but not announced yet)

areohbee
Legend
June 16, 2013

Thanks John & Jarnoh .