Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
...and more:
LrRemoteCommunication
closeNamedConnection
launchApplicationWithPath
pollForMessage
sendMessageToServer
spawnTaskAndConnect
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
Thanks John & Jarnoh .
Copy link to clipboard
Copied
I also tried catalog:createVirtualCopies(), it seems to create virtual copies for active selection. Takes as many copy name strings as many photos are selected. Returns array of LrPhoto instances for the virtual copies.
I guess I can replace my keyboard stuffing virtual copy creation with this function, but it feels a bit awkward that I have to first set master photos with catalog.setSelectedPhotos before calling this method.
EDIT:
I decided to release plugin using catalog:createVirtualCopies() let's see what happens... http://www.capturemonkey.com/excessor-r801
Copy link to clipboard
Copied
jarnoh wrote:
catalog:createVirtualCopies()
I can't get this to create multiple virtual copies .
jarnoh wrote:
it seems to create virtual copies for active selection.
I assume you mean one virtual copy for each selected photo(?)
Active selection meaning the (one) "most" selected photo, i.e. catalog:getTargetPhoto().
jarnoh wrote:
Takes as many copy name strings as many photos are selected.
I tried passing array of copy name strings, and get internal error: "WFSqliteStatement:bind() - illegal data type used as value".
I tried passing one string, which works, but then it only makes one copy.
I tried unpacking the names array (i.e. passing each as a separat parameter) - again, it only makes one copy, it having the first name passed.
What am I doing wrong??
UPDATE:
~~~~~~~
I'm still working on this, but note: return array is not necessarily freshly created virtual copies, nor are all photos returned guaranteed to be virtual - worth checking what gets returned at least until you've got it figured out (I don't, yet).
I've been able to get it to create one copy, just fine, but can't get it to create multiple copies.
Note: omitting all parameters, it creates one copy named "Copy N", or you can pass a string to be used as copy name. I just don't know how to pass multiple names and get it to create multiple copies.
Has anybody actually gotten catalog:createVirtualCopies to create more than one virtual copy (with a single call I mean) ???
PS - Worth noting: this function does not need to be called with catalog write access, strangely enough (but maybe that's part of the problem I'm having? - only does one copy if no catalog write access???).
~~~~~~~
Thanks in advance,
Rob
Copy link to clipboard
Copied
I don't think it does several virtual copies for single photo, you can just select multiple targets and it will create one virtual copy of each, use unpacked array for naming them.
In my tests, I always get fresh new copies (testing on OS X), but I am actually passing just a single photo.
Copy link to clipboard
Copied
Son of a... - that is how it's working now, but that's not how it was working before - I swear it, ya gotta believe me ..
UPDATE:
~~~~~~~
I figured out the problem - It works as advertised in grid view, otherwise: no.
Bug reported (perhaps prematurely) here:
~~~~~~~
Thanx,
R
Copy link to clipboard
Copied
Works for me in Library grid, loupe, develop view....even slideshow. Maybe a Windows specific problem?
Copy link to clipboard
Copied
jarnoh wrote:
Maybe a Windows specific problem?
Could be.
John - does it work for you on Windows? - I mean when more than one photo is selected. It works for me in Windows too (regardless of module/view mode) if only one photo is selected.
Copy link to clipboard
Copied
Ok, I only tested with one photo (I used Excessor to test, it always creates one photo at a time since it required less changes from the LR3/4 keyboard stuffing version)
Copy link to clipboard
Copied
jarnoh wrote:
Had I known you had this plugin, I'd not have bothered with DevPresetLab - sorry for offering competing plugin. I do refer readers to Excessor as a potential alternative...
http://www.robcole.com/Rob/ProductsAndServices/DevPresetLabLrPlugin
Rob
Copy link to clipboard
Copied
jarnoh wrote:
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
Works for me in develop module, but not library module. Hmm... - bad karma?
Error message: "performCommandDesc could not perform command ag.develop.applySnapshotSettings (No perform function available for command.)."
Copy link to clipboard
Copied
Same result here, fails on library and works on develop. Could it be it is just invoking the menu command and failing if it is not available? I wouldn't count on this API being ready to be published...
Copy link to clipboard
Copied
Yeah - anything is possible since all undocumented/unreleased.
But definitely, @Lr5.0, it's using different mechanism than say applyDevelopPreset, which requires catalog write access (applyDevelopSnapshot does not)..
Also, worth noting: snapshot can not be applied to a different image, has to be same image for which it was created. Not unreasonable, but hopefully germaine...
R
Copy link to clipboard
Copied
And here's how to use JPEG thumbnail generation, you just pass it width and height you want and it will call your callback with JPEG data
local ret = photo:requestJpegThumbnail(width, height, function(jpegBinaryString) end)
ret is table with all kinds of interesting stuff
Copy link to clipboard
Copied
jarnoh wrote:
And here's how to use JPEG thumbnail generation, you just pass it width and height you want and it will call your callback with JPEG data
local ret = photo:requestJpegThumbnail(width, height, function(jpegBinaryString) end)
ret is table with all kinds of interesting stuff
Thanks Jarno,
I'm still not sure how to request a histogram, but it seems there should be a way.
This function will probably turn out to be *very* useful.
Rob
Copy link to clipboard
Copied
In this code:
local data
local rec = photo:requestJpegThumbnail( 640, 480, function( image ) data = image end )
while (not data) do
LrTasks.sleep( .1 )
-- make sure loop not infinite...
end
It's worth noting:
* callback is (or may be) executed asynchronously. i.e. callback function may be called a fair while *after* returning from requestJpegThumbnail.
* width & height are "hints", actual size may be substantially larger - no doubt it's tapping the lib previews.
UPDATE:
~~~~~~~
photo:requestJpegThumbnails method only works in Library Module (i.e.NOT in Develop Module). win 7/64.
In develop module the image is blank like a white canvas (filesize OK, block structure OK, metadata OK... - but all image data is, well, blank).
~~~~~~~
UPDATE #2:
~~~~~~~
photo:requestJpegThumbnails method, by default, will recreate preview (thumbnail) if not fresh - that's (presumably) why sometimes the data is available immediately, and sometimes you have to wait a few seconds for it.
~~~~~~~
Rob
Message was UPDATED (twice) by: Rob Cole
Copy link to clipboard
Copied
John R. Ellis wrote:
...and more:
LrRemoteCommunication
closeNamedConnection
launchApplicationWithPath
pollForMessage
sendMessageToServer
spawnTaskAndConnect
If I remember correctly, that LrRemoteCommunication class has been there but not exposed since Lr3 (I think). It'll be interesting to see if they document it for use in Lr5. Or was I dreaming that...(?)
Copy link to clipboard
Copied
Hi,
has anyone figured out how LrRemoteCommunication works?
Any response is appreciated.
Copy link to clipboard
Copied
Not me, I've used xmlRpc (over http) instead.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Any idea what LrPlugin/nativeFunction might be?
Copy link to clipboard
Copied
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")