Some of this is covered under the SDK's "export" functionality, but what I'm proposing isn't something I want to handle as an export (I don't want to do it from Lightroom's export menu).
Two possible approaches:
1. Your plugin could programmatically define a publish service, create a published collection with the desired photos, and then do an export. I think this will give you the most control over thumbnail size and quality and over the asynchronous completion of a presumably very long-running task.
2. Use photo:requestJPEGThumbnail(). But this has a number of issues; see Rob Cole's experience:
So, just to be clear, I can use the Lightroom SDK's export functionality in a plugin that is not actually an export plugin (that is, it isn't accessed through the export menu)?
My research on this subject turned up a function written by Rob Cole in the Elare framework that reads preview images from a catalog. If I can get that to work reliably, it might be the way to do this: http://forums.adobe.com/message/3948416#3948416
John R. Ellis wrote:
1. Your plugin could programmatically define a publish service...
Unless it needs to be a publish service, you may find it simpler to use an LrExportSession - pass photos and export settings and away ya go...
John R. Ellis wrote:
2. Use photo:requestJPEGThumbnail(). But this has a number of issues...
Indeed, this function is not reliable if user is in develop module. If I remember correctly, it just won't work on a photo selected for develop. I think I discovered later that it will work on other photos in filmstrip, if not most-selected (in develop module I mean). And of course one has to wait for a fresh preview, so could take as long as an export. I wish Adobe would have made more than a half-baked implementation for this function. There are some other issues too with this function - it hangs forever if Lr needs to get in there and create the same preview before function is finished, or something like that.
Option #3: use reverse-engineered access to preview subsystem - it works regardless of module, and is easy to get immediate preview - hard to assure a fresh one. Biggest problem is handling orientation and icc-profile and metadata if desired. See PreviewExporter for example:
Yes, to be clear, if you want to export photos on the fly, and are willing to take the time for Lr to do all the work (re-render, orient, ... ) then look at LrExportSession. If you want thumbnails fast, tap the preview subsystem.