Adobe 65007312 Programming Guide

Adobe 65007312 - Photoshop Lightroom - Mac Manual

Adobe 65007312 manual content summary:

  • Adobe 65007312 | Programming Guide - Page 1
    LIGHTROOM SDK 3.0 PROGRAMMERS GUIDE
  • Adobe 65007312 | Programming Guide - Page 2
    such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form organization. Adobe, the Adobe logo, Photoshop, Lightroom, and Flash are either registered trademarks or trademarks of Adobe Systems Incorporated
  • Adobe 65007312 | Programming Guide - Page 3
    this document 10 1 Using the Lightroom SDK 11 Writing plug-ins for Lightroom 11 The Lightroom SDK scripting Services 35 Creating an export or publish service 35 Defining an export service 35 Initialization and termination functions for services 38 Defining a publish service 39 Publish service
  • Adobe 65007312 | Programming Guide - Page 4
    custom sections to the Export or Publishing Manager dialog 53 Restricting existing service functionality 55 Remembering user choices 57 Export presets 58 Settings for publish services and post-process actions 59 Lightroom built-in property keys 59 Export Location section properties 59 File
  • Adobe 65007312 | Programming Guide - Page 5
    a previewed page to Lightroom 142 7 Using ZStrings for Localization 145 ZString format 145 ZString characters and escape sequences 146 The LOC function 147 Localization dictionary files 148 Localization dictionary file format 148 Example dictionary file 149 Supported languages 149 8 SDK
  • Adobe 65007312 | Programming Guide - Page 6
    an export plug-in 168 Create the information file 168 Create the service scripts 169 Displaying a dialog 169 Displaying a custom dialog 170 Create log files 184 Viewing trace information in a platform console 184 10 Defining Metadata: A Walkthrough 187 Adding custom metadata 187 Define
  • Adobe 65007312 | Programming Guide - Page 7
    Contents 7 Define the tags 203 Add the tagset to the gallery 203
  • Adobe 65007312 | Programming Guide - Page 8
    SDK The Adobe Photoshop Lightroom SDK is available for download from: http://www.adobe.com/devnet/photoshoplightroom/ The SDK contains these elements (paths are relative to the location that you choose during installation): LR_SDK/Manual/Lightroom SDK Guide.pdf This programming guide. LR_SDK/API
  • Adobe 65007312 | Programming Guide - Page 9
    -interface controls for Lightroom dialogs and panels. These contain the finished code from the tutorial walkthroughs in Chapter 10 and Chapter 11. Export and Publish Services," explains how to use the SDK to create an export plug-in, which customizes the behavior of Lightroom's Export and Publishing
  • Adobe 65007312 | Programming Guide - Page 10
    : A Tutorial Example," walks through a "Hello World" tutorial to help you create your first plug-in. X Chapter 10, "Defining Metadata: A Walkthrough," shows how to define Lightroom-specific metadata properties for your photos. X Chapter 11, "Web Gallery Plug-ins: A Tutorial Example," shows how to
  • Adobe 65007312 | Programming Guide - Page 11
    images to locations other than files on the local computer. See Chapter 3, "Creating Export and Publish Services." X Metadata: You can define customized public or private metadata fields for Lightroom. Public or private metadata can be associated with individual photos. You can also define new ways
  • Adobe 65007312 | Programming Guide - Page 12
    as a table containing a suite of functions. This is somewhat like the Lua module; however, Lightroom does not use or support the module system that was introduced in Lua 5.1 (see http://www.lua.org/manual/5.1/manual.html#5.3). Lua does not have an object-oriented programming model, but it does allow
  • Adobe 65007312 | Programming Guide - Page 13
    operations not otherwise available in the Lua language. Provides MD5 digest services. Provides a mechanism to store passwords in a secure fashion. Provides string manipulation utilities. Provides information about the environment in which Lightroom is running, such as whether it is 32-bit or 64-
  • Adobe 65007312 | Programming Guide - Page 14
    (). Others are created and passed to you by Lightroom. The Lightroom SDK defines these classes; for complete details, see the Lightroom SDK API Reference. Class LrCatalog LrCollection Description Provides access to a Lightroom catalog. Provides access to a photo collection. Object creation
  • Adobe 65007312 | Programming Guide - Page 15
    CHAPTER 1: Using the Lightroom SDK The Lightroom SDK scripting environment 15 Class Description Object creation LrCollectionSet Provides access to a photo collection set. LrColor Encapsulates a color. Returned by: LrCatalog:createCollectionSet() LrCatalog:getCollectionSets() LrCollectionSet
  • Adobe 65007312 | Programming Guide - Page 16
    viewed with an external log-viewer application. Import constructor: local LrLogger = import 'LrLogger' LrPhoto A single photo or virtual copy in Lightroom's active catalog. Returned by many functions of LrCatalog, LrCollection, LrExportSession and so on. Many classes provide access to the photo
  • Adobe 65007312 | Programming Guide - Page 17
    LrPublishService Provides access to a named publishing service. Returned by LrCatalog:getPublishServices() LrRecursionGuard Provides with the namespace function LrView.osFactory(). X When extending a Lightroom dialog, a factory object is passed to sectionsForTopOfDialog() and
  • Adobe 65007312 | Programming Guide - Page 18
    task are reported to the user and not silently forgotten. Lightroom provides predefined error dialogs that you can customize with explanatory messages ) -- The code needed to perform your task goes here -- For illustration, force an error here, throw error two different ways if showInternalError then
  • Adobe 65007312 | Programming Guide - Page 19
    defines built-in namespaces and global functions, of which only a subset are supported in the Lightroom SDK Lua environment, as follows: Lua global functions X Available in Lightroom: assert(), dofile(), error(), getmetatable(), ipairs(), load(), loadfile(), loadstring(), next(), pairs(), pcall
  • Adobe 65007312 | Programming Guide - Page 20
    manage a task, which is a kind of lightweight process that runs cooperatively on Lightroom's main (user interface) thread. If your service defines a lengthy export operation that would block the main Lightroom process, you should run it as a background task, using functions such as LrFunctionContext
  • Adobe 65007312 | Programming Guide - Page 21
    If you use 0 as the condition of an if or while statement for example, the statement is executed, because the number 0 is a true value. X Lightroom defines Boolean globals, WIN_ENV and MAC_ENV, which you can use to determine which platform your script is running on. The LrSystemInfo namespace (first
  • Adobe 65007312 | Programming Guide - Page 22
    file installed in a standard plug-in folder identifies your plug-in scripts to Lightroom, and associates the plug-in with a unique name. X You can add or publish destination with an Export Service Provider or Publish Service Provider. Such a service can also customize the Export or Publishing
  • Adobe 65007312 | Programming Guide - Page 23
    automatically disabled. Note that com.adobe.*, which is used in the examples, is reserved for plug-ins written by Adobe; your own plug-ins will loaded in Lightroom 2.0 or newer, the Plug-in Manager displays the title of the first Export Service Provider, or if no Export Service Provider is
  • Adobe 65007312 | Programming Guide - Page 24
    . The version number is for your own use, and need not relate to Lightroom's version number. The table has these members: major (number) minor (number string; see "The LOC function" on page 147. Ignored in any Lightroom version older than 2.0. Optional table of tables These allow you to add new
  • Adobe 65007312 | Programming Guide - Page 25
    for another filter that must be used with this one. Can be combined with other services (export services, custom metadata) or can be the only service provided by the plug-in. Ignored in any Lightroom version older than 2.0. Optional table of tables Adds one or more new export destinations or
  • Adobe 65007312 | Programming Guide - Page 26
    other services (export services, export filters) or can be the only service provided by the plug-in. Ignored in any Lightroom version Lightroom menus: return { LrSdkVersion = 3.0, LrSdkMinimumVersion = 1.3, -- minimum SDK version required by this plug-in LrToolkitIdentifier = 'com.adobe.lightroom
  • Adobe 65007312 | Programming Guide - Page 27
    convenience, you can use the suffix .lrdevplugin during development, and change the extension to .lrplugin for delivery. The .lrdevplugin suffix is recognized by Lightroom but does not trigger the package behavior in the Mac OS Finder. A plug-in folder can reside in any location on the hard drive
  • Adobe 65007312 | Programming Guide - Page 28
    dialog. For example, in the following figure, the plug-in called "Plug-in Info Sample" defines two custom sections, one above and one below the Lightroom-defined sections. They appear only when the plug-in is selected in the list. The sections are collapsible, and you can define a descriptive string
  • Adobe 65007312 | Programming Guide - Page 29
    plug-ins in the standard Modules folder where other Lightroom settings are stored: In Mac OS (current user) ~/Library/Application Support/Adobe/Lightroom/Modules In Mac OS (all users) /Library/Application Support/Adobe/Lightroom/Modules In Windows XP C:\Documents and Users\username\Application
  • Adobe 65007312 | Programming Guide - Page 30
    to load, or encounters an error at any stage of its operation. The Lightroom SDK does not supply a development environment in which to debug your plug-ins, same items are defined slightly differently in an Export Service Provider to run when the service is selected or deselected in the Export dialog;
  • Adobe 65007312 | Programming Guide - Page 31
    SDK version required by this plug-in LrToolkitIdentifier = 'com.adobe.lightroom.sample.plug-in-info', LrPluginName = LOC "$$$/PluginInfo/Name= called when your plug-in is selected or deselected. To do so, the service definition script for your Plug-in Info Provider should return these table entries,
  • Adobe 65007312 | Programming Guide - Page 32
    CHAPTER 2: Writing a Lightroom Plug-in Customizing plug-in load behavior 32 selected in the Export dialog, never from the Plug-in Manager dialog. See "Initialization and termination functions for services" on page 38. The propertyTable parameter for both functions is an empty, observable table
  • Adobe 65007312 | Programming Guide - Page 33
    CHAPTER 2: Writing a Lightroom Plug-in Defining menu items for a plug-in 33 When adding sections to the Plug-in Manager, the propertyTable parameter for both functions is an
  • Adobe 65007312 | Programming Guide - Page 34
    CHAPTER 2: Writing a Lightroom Plug-in Defining menu items for a plug-in 34 file (String) The name of the Lua file (service definition script) to be executed when the menu item is chosen. See "Defining an export service" on page 35. enabledWhen (String, optional) A condition under which to
  • Adobe 65007312 | Programming Guide - Page 35
    change the photos. To publish, the user establishes a connection to a destination (typically, but not necessarily, a web service) in the Publishing Manager dialog. By default, Lightroom provides publish service support for user-selected locations on the local hard drive and Flickr. As with export
  • Adobe 65007312 | Programming Guide - Page 36
    dialog. These types of customizations are defined: Z Restrict the built-in services offered by the Export dialog. Z Customize the Export dialog by defining 57. These are added to the built-in settings defined by Lightroom; see "Lightroom built-in property keys" on page 59. A callback function that
  • Adobe 65007312 | Programming Guide - Page 37
    dialog. Default is false. (This is tied to LR_export_destinationType; see "Lightroom built-in property keys" on page 59.) If the user selects this a hidden temporary folder on the local hard drive. When the Export Service Provider has completed its work, this folder and its contents are deleted
  • Adobe 65007312 | Programming Guide - Page 38
    callback function to do that. See "Customizing the Export and Publishing Manager dialogs" on page 52. X For a publish service, Lightroom creates a new publish service in the Publish Services panel that can be used later to publish images through your plug-in. cancel The user clicked the "Cancel
  • Adobe 65007312 | Programming Guide - Page 39
    CHAPTER 3: Creating Export and Publish Services Defining a publish service 39 Defining a publish service Starting with version 3.0, Lightroom allows you to send photos to a local or network destination for publication. The publication process is similar to the export process, and the Publishing
  • Adobe 65007312 | Programming Guide - Page 40
    A publish service can manage collections or folders on the remote export destination from within the Lightroom catalog. X A publish service can retrieve Download comments and ratings (if applicable) from the remote service. Publish service options To define the functionality of your publish service,
  • Adobe 65007312 | Programming Guide - Page 41
    , each post-process action can provide only one section for the dialog, which is always inserted after Lightroom's built-in sections, and before any "bottom" sections defined by the Export Service Provider. Export Filter Providers cannot define presets of their own, but can be included in an Export
  • Adobe 65007312 | Programming Guide - Page 42
    CHAPTER 3: Creating Export and Publish Services Adding an export post-process action 42 An action that has been inserted is flagged with a check mark; when it is selected, the Remove button
  • Adobe 65007312 | Programming Guide - Page 43
    the FTP-upload export destination and clicks Export, the service provider requests an export rendition for each photo that is active at the time. If the user does not choose any actions, the request is satisfied directly by Lightroom using LrExportRendition. If the user inserts Color, the dialog
  • Adobe 65007312 | Programming Guide - Page 44
    CHAPTER 3: Creating Export and Publish Services Adding an export post-process action 44 user your filters to be recognized. If you set LrSdkMinimumVersion = 1.3, the plug-in can be loaded in Lightroom 1.3, but the post-process actions are ignored. To declare one or more post-process actions, add
  • Adobe 65007312 | Programming Guide - Page 45
    in the Export dialog. See "Initialization and termination functions for services" on page 38. exportPresetFields A set of export preset settings your plug-in (in addition to the built-in settings defined by Lightroom). If provided, these fields are transferred from the Export dialog's property
  • Adobe 65007312 | Programming Guide - Page 46
    CHAPTER 3: Creating Export and Publish Services Adding an export post-process action 46 Removing photos from the ) exportSettings.LR_format = 'TIFF' return os.tmpname() -- ... if you wanted Lightroom to generate TIFF files -- and override the configured filename when providing -- input images
  • Adobe 65007312 | Programming Guide - Page 47
    actions are executed During an export operation, rendition requests and state information are passed up a chain of processors from the Export Service Provider to the Lightroom built-in render engine, and rendered photos are passed back down again. The sequence is followed for each photo in the list
  • Adobe 65007312 | Programming Guide - Page 48
    When there are no more actions, the final downstream consumer is the Export Service Provider that sends the rendered photo to the final destination. When the user starts the export operation by clicking Export, Lightroom constructs an LrExportSession object with the settings and photos chosen in the
  • Adobe 65007312 | Programming Guide - Page 49
    . If no such function exists, a default one is provided that performs the steps described below. IMPORTANT: Each of the providers (the export service, filters, and Lightroom's built-in rendering engine) runs in its own task (using LrTasks), so these loops operate in parallel. It is likely that each
  • Adobe 65007312 | Programming Guide - Page 50
    CHAPTER 3: Creating Export and Publish Services Adding an export post-process action 50 5. For each filter, if a requests, the requests are finally passed to Lightroom's built-in rendering engine. Stage 4: Processing rendered photos As Lightroom completes each rendition request, it signals
  • Adobe 65007312 | Programming Guide - Page 51
    export is initiated by calling LrExportSession directly. Final processing of rendered photos The processRenderedPhotos() service entry allows you to control what happens to each exported photo after it is rendered by Lightroom and after all post-process actions have been applied to it. This is the
  • Adobe 65007312 | Programming Guide - Page 52
    actions, it completes the export operation by sending the resulting image file to the export-service code, which handles the actual export to the user-selected destination. By default, Lightroom provides export services for a user-selected location in the local file system, or the CD/DVD drive
  • Adobe 65007312 | Programming Guide - Page 53
    gives you a choice of destinations: Your plug-in can provide an export service that allows the user to choose a different destination, such a remote site, and include with your plug-in, as well as those defined by Lightroom for export operations; see "Remembering user choices" on page 57. Adding
  • Adobe 65007312 | Programming Guide - Page 54
    dialog, the propertyTable parameter for both functions is the property table containing the plug-in and Lightroom-defined export settings. When your plug-in is being used as a publish service provider, the property table contains additional values that tell you about the publishing status; see
  • Adobe 65007312 | Programming Guide - Page 55
    this custom section at the top of the Export dialog (when defined by an LrExportServiceProvider entry): Restricting existing service functionality Your service can restrict the built-in services offered by the Export and Publishing Manager dialogs, by hiding some of the built-in sections that are
  • Adobe 65007312 | Programming Guide - Page 56
    in pixel units; all mention of print units such as inches, centimeters, and pixels-per-inch are hidden. Default is false. The rest of the service table entries that restrict existing functionality in the dialog come in positive and negative forms; that is, you can list the features to be included
  • Adobe 65007312 | Programming Guide - Page 57
    2.0. This section is now only available with the built-in "Export to Files on Disk" service. If specified, it is ignored by Lightroom 2.0 or newer. Remembering user choices You typically define properties for your own export or publish operation, whose key names, values, and usage are entirely
  • Adobe 65007312 | Programming Guide - Page 58
    are shown only in the Publishing Manager dialog. If you wish to create a predefined preset for your export-service plug-in, to be loaded along with your plug-in and appear in the Lightroom Presets list, you must: 1. Make the value selections in the Export dialog. 2. Use Add to save a User Preset
  • Adobe 65007312 | Programming Guide - Page 59
    activate the post-process action for a particular export operation, user choices for that action are captured in any preset created for that export service. Lightroom built-in property keys Your export operation makes use of the settings that you have defined for your plug-in (see "Remembering user
  • Adobe 65007312 | Programming Guide - Page 60
    CHAPTER 3: Creating Export and Publish Services Lightroom built-in property keys 60 LR_reimport_stackWithOriginal LR_collisionHandling Boolean. True when the "Stack With Original " option is checked, false when it is unchecked. This is only
  • Adobe 65007312 | Programming Guide - Page 61
    CHAPTER 3: Creating Export and Publish Services Lightroom built-in property keys 61 Pattern Replaced by {{image_originalName_number_suffix}} Original number suffix {{copy_name}} Copy name {{custom_token}} Custom Text (the value of LR_tokenCustomString) Sequence and Date
  • Adobe 65007312 | Programming Guide - Page 62
    }} {{com.adobe.iptcSubjectCode}} {{com.adobe.intellectualGenre}} {{com.adobe.scene}} {{com.adobe.location}} {{com.adobe.isoCountryCode}} {{com.adobe.headline}} {{com.adobe.city}} {{com.adobe.state}} {{com.adobe.country}} {{com.adobe.jobIdentifier}} {{com.adobe.instructions}} Lightroom built-in
  • Adobe 65007312 | Programming Guide - Page 63
    com.adobe.rating.string}} {{com.adobe.colorLabels.string}} Lightroom built-in property keys 63 Replaced by Provider Source Rights Usage Terms Copyright Info URL Dimensions Cropped Exposure Focal Length Focal Length 35mm Brightness Value Exposure Bias Subject Distance ISO Speed Rating Flash Exposure
  • Adobe 65007312 | Programming Guide - Page 64
    3: Creating Export and Publish Services File Settings section properties Lightroom built-in property keys 64 LR_format Size To:" option is checked, false when it is unchecked. When true, Lightroom chooses the quality setting that best matches the desired file size. LR_jpeg_limitSize Number
  • Adobe 65007312 | Programming Guide - Page 65
    3: Creating Export and Publish Services Lightroom built-in property keys 65 The following apply only if LR_format = DNG LR_DNG_previewSize String. JPEG preview size. One of: LR_DNG_compatability none medium large Number. The oldest version of Adobe Camera Raw/Photoshop that can read these
  • Adobe 65007312 | Programming Guide - Page 66
    CHAPTER 3: Creating Export and Publish Services Lightroom built-in property keys 66 LR_size_units String. Size constraint units. . When watermarking is enabled, the unique identifier of the watermark to use. Lightroom assigns this ID when the user creates a new watermarking preset. You cannot
  • Adobe 65007312 | Programming Guide - Page 67
    your plug-in should set this value to nil. In response to that change, Lightroom enables the Export or Save button (if no other error conditions exist). Ignored in versions earlier than 2.0. Publish Service properties These properties are part of the settings table passed to the following callbacks
  • Adobe 65007312 | Programming Guide - Page 68
    return { LrSdkVersion = 3.0, LrToolkitIdentifier = 'com.adobe.lightroom.metadata.sample', LrPluginName = LOC "$$$/CustomMetadata/PluginName= metadata tagsets (see "Adding custom metadata tagsets" on page 73), export services and/or filters, but need not do so. Limitations of custom metadata in
  • Adobe 65007312 | Programming Guide - Page 69
    previousSchemaVersion, and progressScope. When the plug-in is first installed, previousSchemaVersion is nil. See example below. Optional. When false (the default), Lightroom attempts to automatically update metadata from old field definitions to new. If you prefer to handle this in your own plug-in
  • Adobe 65007312 | Programming Guide - Page 70
    search for photos that contain the old version of the field and manually migrate values. string Optional. If this field is displayed in the an on-line service that is the export destination, or other cross-reference information. string Optional. If this field is present, Lightroom disallows any
  • Adobe 65007312 | Programming Guide - Page 71
    does not have a title field. You might use a field like this -- to store a photo ID from an external database or web service. }, { id = 'randomString', title = LOC "$$$/Sample/Fields/RandomString=Random String", dataType = 'string', -- Specifies the data type for this field. }, { id = 'modelRelease
  • Adobe 65007312 | Programming Guide - Page 72
    of the with___Do functions yourself. catalog:assertHasPrivateWriteAccess( "SampleMetadataDefinition.updateFromEarlierSchemaVersion" ) local myPluginId = 'com.adobe.lightroom.metadata.sample' if previousSchemaVersion == 1 then local photosToMigrate = catalog:findPhotosWithProperty( myPluginId,'siteId
  • Adobe 65007312 | Programming Guide - Page 73
    your own. Your plug-in can define a named metadata tagset, which can include fields defined by your plug-in, by other plug-ins, or by Lightroom. This is the Info.lua file for a minimal plug-in that defines a tagset: return { LrSdkVersion = 3.0, LrToolkitIdentifier = 'com
  • Adobe 65007312 | Programming Guide - Page 74
    -tagset provider can appear in the same plug-in with export-service and export-filter providers, and with simple Metadata Providers. The metadata below. Optional. When the field name is the special value 'com.adobe.label', this is the localizable string to use as the section label. Certain
  • Adobe 65007312 | Programming Guide - Page 75
    LOC "$$$/Metadata/SampleLabel=Section Label" }, 'com.adobe.dateCreated', 'com.adobe.location', 'com.adobe.city', 'com.adobe.state', 'com.adobe.country', 'com.adobe.isoCountryCode', 'com.adobe.GPS', 'com.adobe.GPSAltitude', 'com.adobe.lightroom.metadata.sample.randomString', }, } Searching for photos
  • Adobe 65007312 | Programming Guide - Page 76
    ) iptc (string) Any IPTC metadata; that is, any text in a field that is indexed by Lightroom. exif (string) Any EXIF metadata; that is, any text in a field that is indexed by Lightroom. captureTime (date) touchTime (date) Edit Date camera (string, with exact match) cameraSN (string, with
  • Adobe 65007312 | Programming Guide - Page 77
    CHAPTER 4: Working with Metadata Searching for photos by metadata values 77 country (string, with exact match) state (string, with exact match) city (string, with exact match) location (string, with exact match) creator (string, with exact match) jobIdentifier (string, with exact match)
  • Adobe 65007312 | Programming Guide - Page 78
    CHAPTER 4: Working with Metadata Searching for photos by metadata values 78 == "is", only valid for items that can have an exact match, != "is not", only valid for items that can have an exact match X For Boolean values, one of "isTrue", "isFalse" X For enumerated values, one of == (is), != (
  • Adobe 65007312 | Programming Guide - Page 79
    CHAPTER 4: Working with Metadata Searching for photos by metadata values 79 thisMonth thisYear "is in this month" "is in this year" value The value to match against must be of the type indicated for the criteria. Additional parameters value2 and value_unit are used with specific types and
  • Adobe 65007312 | Programming Guide - Page 80
    searches interactively If you are unsure how to construct a particular search, you can make Lightroom build it for you. To do this: 1. Construct the search as a Smart Collection in Lightroom: 2. Right click the resulting collection in the Collections panel and choose "Export Smart Collection
  • Adobe 65007312 | Programming Guide - Page 81
    CHAPTER 4: Working with Metadata Searching for photos by metadata values 81 5. Edit the resulting code to change value to searchDesc, and include it in your call to findPhotos(). 6. Make any other appropriate changes in the code. In this example, for instance, you would not need the combine
  • Adobe 65007312 | Programming Guide - Page 82
    Plug-in Manager dialog or Export dialog, above and/or below the Lightroom standard sections. The custom sections are displayed when the user chooses your export in the Plug-in Manager or Export dialog using these service-script entries: sectionsForTopOfDialog = function( viewFactory, propertyTable )
  • Adobe 65007312 | Programming Guide - Page 83
    customized dialog box. All dialog boxes are modal, meaning that when the dialog is invoked, no other actions can be taken in the Lightroom UI until the dialog is dismissed. Displaying predefined dialog boxes The predefined dialog boxes display: X Messages Message dialogs display your text message to
  • Adobe 65007312 | Programming Guide - Page 84
    customized dialog box, which you can, for example, invoke from a menu item that your plug-in adds to the Lightroom menu bar, using one of the menu service items: LrExportMenuItems, LrLibraryMenuItems, or LrHelpMenuItems. Most of the contents of this dialog are defined by an LrView hierarchy that
  • Adobe 65007312 | Programming Guide - Page 85
    control is a child of that container. For complete details of how to create the controls and specify their appearance and behavior, see the Lightroom SDK API Reference. The following table summarizes the available control types and lists their type-specific properties. X All controls have the shared
  • Adobe 65007312 | Programming Guide - Page 86
    CHAPTER 5: Creating a User Interface for Your Plug-in User interface elements 86 Control type checkbox color_well combo_box edit_field Description Type-specific properties Displays the title text with a platform-style checkbox button. A checkbox is checked (selected) when its value is equal to
  • Adobe 65007312 | Programming Guide - Page 87
    CHAPTER 5: Creating a User Interface for Your Plug-in User interface elements 87 Control type Description Type-specific properties password_field An editable text field that obscures the entered text, displaying only bullet characters. All edit and text properties. See "Edit-field view
  • Adobe 65007312 | Programming Guide - Page 88
    range. integral: True to change only by integer increments. Default is false. Text that typically does not respond to user input, such as a label or instructions. Although the user cannot change the text, it can still be made dynamic by binding the title to a data value; see "Binding UI values to
  • Adobe 65007312 | Programming Guide - Page 89
    CHAPTER 5: Creating a User Interface for Your Plug-in Containers and placement controls User interface elements 89 Buttons. selection, edit and text controls
  • Adobe 65007312 | Programming Guide - Page 90
    CHAPTER 5: Creating a User Interface for Your Plug-in Other controls User interface elements 90 View properties Properties in container and control nodes affect the layout of the controls, and their appearance. Layout properties, and certain view properties, are available to all nodes, both
  • Adobe 65007312 | Programming Guide - Page 91
    CHAPTER 5: Creating a User Interface for Your Plug-in User interface elements 91 General view properties Of the properties that are available in both containers and controls, many are connected with layout behavior; these are discussed separately in "Determining layout" on page 107. The following
  • Adobe 65007312 | Programming Guide - Page 92
    CHAPTER 5: Creating a User Interface for Your Plug-in User interface elements 92 Control node view properties These properties are available in control nodes of all types, but not in containers. Control node property enabled Datatype Boolean font string or table size string Description When
  • Adobe 65007312 | Programming Guide - Page 93
    is 0.1. If field is numeric, the amount to increment the value when the SHIFT key is held down. If the precision is 0, default is 10; otherwise default is 1. A function called to validate the value: myValidate( view, value ) Returns result, value, message: result: (Boolean) True if value was valid
  • Adobe 65007312 | Programming Guide - Page 94
    . This table contains both export settings that you have defined for your plug-in (see "Remembering user choices" on page 57) and Lightroom-defined export settings (see "Lightroom built-in property keys" on page 59). The propertyTable is automatically set as the default bound table for all of the UI
  • Adobe 65007312 | Programming Guide - Page 95
    is hidden and a Compression pop-up menu is shown. For PSD and DNG, both of these controls (and their labels) are hidden. To accomplish this, Lightroom binds the Format pop-up menu's value property to the LR_format setting. Then the visible property of the slider and its label are bound to
  • Adobe 65007312 | Programming Guide - Page 96
    synchronized. For example: visible = LrView.bind( "LR_export_useSubfolder" ) In this case, both the local property (visible) and the bound table item (a Lightroom-defined export setting) have Boolean values. Setting the use-subfolder preference to true (in the Export dialog, for instance) makes the
  • Adobe 65007312 | Programming Guide - Page 97
    program data. An observable table must be created with a function context, so that Lightroom can clean up the notifications if anything goes wrong. (See "Using function contexts = LrBinding.makePropertyTable( context ) properties.url = "http://www.adobe.com" -- create a settings value -- add code to
  • Adobe 65007312 | Programming Guide - Page 98
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 98 For example: LrFunctionContext.callWithContext("showCustomDialog", function( context ) local myPropTable = LrBinding.makePropertyTable( context ) mypropTable:addObserver( 'mySetting', function( properties,
  • Adobe 65007312 | Programming Guide - Page 99
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 99 f:checkbox { title = "Value will be string", value = bind 'checkbox_state', -- bind to the key value checked_value = 'checked', -- this is the initial state unchecked_value = 'unchecked', -- when the user
  • Adobe 65007312 | Programming Guide - Page 100
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 100 Binding pop-up menu selections The pop-up menu and the menu component of a combo box allow you to specify a set of choices, using an items table; each item entry is a table containing a title and value. The
  • Adobe 65007312 | Programming Guide - Page 101
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 101 local LrFunctionContext = import "LrFunctionContext" local LrStringUtils = import "LrStringUtils" local LrView = import "LrView" LrFunctionContext.callWithContext( 'bindingExample', function( context ) local
  • Adobe 65007312 | Programming Guide - Page 102
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 102 local LrView = import "LrView" -- Create an observable table within a function context. LrFunctionContext.callWithContext( 'bindingExample', function( context ) -- Obtain the view factory. local f = LrView.
  • Adobe 65007312 | Programming Guide - Page 103
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 103 Complex bindings The LrBinding functions provide a particular, limited set of value transformations. To specify more complex bindings, the argument to LrView.bind() can be a table with these items: key
  • Adobe 65007312 | Programming Guide - Page 104
    a custom function for a one-way transformation, return the value LrBinding.kUnsupportedDirection to indicate that one or the other direction is not supported by your transformation. Here is an example of a one-way transformation. This example shows a transformation that makes a text display visible
  • Adobe 65007312 | Programming Guide - Page 105
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 105 transform = function( value, fromTable ) if fromTable then return value ~= nil and value ~= '' -- check that key has a value end return LrBinding.kUnsupportedDirection end, } }, } local result = LrDialogs.
  • Adobe 65007312 | Programming Guide - Page 106
    CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 106 operation transform Required. A function defining an operation to perform on the key values; the result of this operation is passed to the transform function. This function is called when any specified key
  • Adobe 65007312 | Programming Guide - Page 107
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 107 spacing = f:label_spacing(), f:static_text { title = "Type more:", alignment = 'right', width = LrView.share( 'label_width' ), }, f:edit_field { fill_horizonal = 1, width_in_chars = 20, immediate = true, value = LrView.
  • Adobe 65007312 | Programming Guide - Page 108
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 108 Relative placement of sibling nodes These properties determine how child nodes are placed relative to one another. They apply only to containers. A margin is the interior margin of a container, the distance between the
  • Adobe 65007312 | Programming Guide - Page 109
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 109 Layout property fill place_horizontal place_vertical width height Datatype number [0..1] number [0..1] number Description The default fill value, if a specific horizontal or vertical value is not provided. The place
  • Adobe 65007312 | Programming Guide - Page 110
    LrView.osFactory() --obtain a view factory local properties = LrBinding.makePropertyTable( context ) -- make a table properties.url = "http://www.adobe.com" -- initialize setting local contents = f:row { -- create UI elements spacing = f:label_spacing(), bind_to_object = properties, -- default bound
  • Adobe 65007312 | Programming Guide - Page 111
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 111 actionVerb = "Go", -- label for the action button } ) if result == 'ok' then -- action button was clicked LrHttp.openUrlInBrowser( properties.url ) end end ) Making labels line up Typically, a dialog contains vertical
  • Adobe 65007312 | Programming Guide - Page 112
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 112 spacing = f:label_spacing(), f:static_text { title = "Occupation:", alignment = "right", width = LrView.share "label_width", -- the shared binding }, f:edit_field { width_in_chars = 20, }, }, } local result = LrDialogs.
  • Adobe 65007312 | Programming Guide - Page 113
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 113 This example creates the overlapping views shown in the figure, where the controls shown below the format pop-up depend on the selection in the pop-up menu. local LrBinding = import "LrBinding" local LrDialogs = import "
  • Adobe 65007312 | Programming Guide - Page 114
    CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 114 title = "Compression:", }, f:popup_menu { items = { { title = "None", value = 'none' }, { title = "LZW", value = 'lzw' }, { title = "ZIP", value = 'zip' }, }, value = LrView.bind 'tiff_compression',-- sets a TIFF value
  • Adobe 65007312 | Programming Guide - Page 115
    folder, which you must place in the following directory according to your operating system: IN MAC OS: userhome/Library/Application Support/Adobe/Lightroom/Web Galleries/ IN WINDOWS: LightroomRoot\shared\webengines The name of the plug-in folder must end with .lrwebengine; for example, myWebPlugin
  • Adobe 65007312 | Programming Guide - Page 116
    CHAPTER 6: Writing a Web-engine Plug-in Defining the data model 116 LuaPage templates about.html detail.html foot.html grid.html head.html Resources resources/ style sheets css/ie6.css ie7.css master.css JavaScript js/live_update.js images misc/icon_fullsize.png shadow-grid.gif shadow.png
  • Adobe 65007312 | Programming Guide - Page 117
    resources (such as CSS or images). The About box is displayed when the user chooses Web > About [thisEngine]. Boolean, true if this web engine supports the Live Update mechanism. See "Web HTML Live Update" on page 139. This example shows the top-level entries from the galleryInfo.lrweb file of
  • Adobe 65007312 | Programming Guide - Page 118
    Writing a Web-engine Plug-in Defining the data model 118 title = LOC "$$$/AgWPG/Templates/HTML/Title=Lightroom HTML Gallery", id = "com.adobe.wpg.templates.jardinePro", galleryType = "lua", maximumGallerySize = 50000, aboutBoxFile = "about.html", supportsLiveUpdate = true, model = {...} } Here is
  • Adobe 65007312 | Programming Guide - Page 119
    in this format: [ "appearance.cssClassName.cssPropertyName" ] = value In addition, for each unique name, you must also add an entry that tells Lightroom what CSS selector to use for that name, in this form: [ "appearance.cssClassName.cssID" ] = selectorName For example, to control the background
  • Adobe 65007312 | Programming Guide - Page 120
    in Defining the data model 120 lightroomApplication.property identityPlateExport jpegQuality useWatermark outputSharpeningOn outputSharpening These properties control how Lightroom behaves when creating the gallery: identityPlateExport-If your gallery can encorporate a PNG version of the identity
  • Adobe 65007312 | Programming Guide - Page 121
    CHAPTER 6: Writing a Web-engine Plug-in Defining the data model 121 The function returns a table of view descriptions by name, with entries that correspond to the control panels at the right of the Web module. labels colorPalette appearanceConfiguration outputSettings The Site Info panel, which
  • Adobe 65007312 | Programming Guide - Page 122
    of type LrWebViewFactory, and it defines these additional functions for creating UI content suitable to the Web module (see the Lightroom SDK API documentation for details): panel_content subdivided_sections header_section_label Creates a top-level panel in the Web module, which contains sections
  • Adobe 65007312 | Programming Guide - Page 123
    CHAPTER 6: Writing a Web-engine Plug-in Defining the data model 123 content_column slider_content_column checkbox_and_color_row color_content_column content_section header_section These create column-style containers for controls within a section. Some are generic, and some are specialized to
  • Adobe 65007312 | Programming Guide - Page 124
    : Defining the data model 124 The localized title text appears as the display name for the label. The checkbox and presets menu are supplied by Lightroom. The value of the value entry appears as the default value for the Custom Text preset choice. To incorporate the user's choice of text in
  • Adobe 65007312 | Programming Guide - Page 125
    logic using Lua's basic math and string manipulation functions. Lightroom also provides a function, LrColorToWebColor, that converts an LrColor preview for your gallery should be implemented. This entry references a simple Flash® movie (which you must implement and include in the web-engine folder
  • Adobe 65007312 | Programming Guide - Page 126
    = 'yes'; Once your ready function returns "yes", Lightroom takes a screenshot of the Flash movie and terminates its execution (in order to reduce CPU that you created in Flash, or simply by using the drawing primitives of the ActionScript programming language. For example: var cellSize = 10; for( x =
  • Adobe 65007312 | Programming Guide - Page 127
    , and so on. Uses a LuaPage template to build a page for each photo in the current Lightroom selection. Uses a LuaPage template to build a page for each grid of photos in the current Lightroom selection. Generates a CSS file using the appearance properties of your data model. Exports an identity
  • Adobe 65007312 | Programming Guide - Page 128
    used as the source: AddResources "resources" AddPhotoPages Uses a LuaPage template to build a separate page for each photo in the current Lightroom selection. Inputs filetype variant destination template Optional. A file extension for the pages. Default is "html". Optional. A suffix to append to
  • Adobe 65007312 | Programming Guide - Page 129
    .html', variant = '_large', destination = "content", } AddGridPages Uses a LuaPage template to build a page for each grid of photos in the current Lightroom selection. Inputs filetype destination template rows columns (Optional) A file extension for the pages. Default is "html". The path to the
  • Adobe 65007312 | Programming Guide - Page 130
    CHAPTER 6: Writing a Web-engine Plug-in Web SDK manifest API 130 In addition, if you use AddGridPages() to add any page, all of the LuaPages in your gallery can use these environment variables: numGridPages The number of grid pages in the gallery filenameOfGridPage( pageNumber ) A function
  • Adobe 65007312 | Programming Guide - Page 131
    = "Background } IdentityPlate Exports an identity plate as a PNG file, if the user chooses to use it. During a Lightroom preview of the web gallery, the PNG file is always generated, to support a live update of the model-defined property that controls identity-plate use. If the user chooses not to
  • Adobe 65007312 | Programming Guide - Page 132
    tags belonging to this tagset. For example, "lr". (string) A path to the tagset definition file. The special path "com.adobe.lightroom.default" loads the default tagset. Example 1. Create a tagset file called myTags.lrweb.: tags = { fancyQuote = { startTag = 'write( [[
  • Adobe 65007312 | Programming Guide - Page 133
    -only variables are available: Variable Description getImage(imageIndex) A function that returns an imageProxy. mode X When the gallery is being previewed inside Lightroom, the value is the string "preview". X During export, upload or preview in browser, it is set to "publish". numImages The
  • Adobe 65007312 | Programming Guide - Page 134
    CHAPTER 6: Writing a Web-engine Plug-in LuaPage syntax 134 Variable includeFile() Description An execution-time function that allows a page to include another file using runtime logic to specify which file. For example: My web gallery This is the grid.html file.
  • Adobe 65007312 | Programming Guide - Page 135
    Lua-language tag definition, which it then compiles and executes to product the HTML output. There is built-in set of tags included with the Lightroom SDK, which you can also include and use in your LuaPages. Defining custom tags To define a tagset in Lua, specify a tags table. This is a table
  • Adobe 65007312 | Programming Guide - Page 136
    the built-in default tagset, substitute the special value "com.adobe.lightroom.default" for the path: importTags( "lr", "com.adobe.lightroom.default" ) By convention, the built-in tags are imported the tag and its supporting function in the tagset file, myTags.lua: globals = { myFn = function( x )
  • Adobe 65007312 | Programming Guide - Page 137
    When the Lua code is executed, this produces text as its HTML output: You said, "Helloworld!" Lightroom built-in tagset Lightroom includes a default set of tags, defined in the "com.adobe.lightroom.default" tagset. This tagset is typically imported into the lr: tagset namespace, but you can import
  • Adobe 65007312 | Programming Guide - Page 138
    CHAPTER 6: Writing a Web-engine Plug-in Web SDK tagsets 138 This defines a simple grid with only one cell, which displays a photo from the referenced file. It uses a variable, image, which is evaluated at run time as a reference to the currently selected photo. The following local variables are
  • Adobe 65007312 | Programming Guide - Page 139
    button for the last page (the case in which there is no next page). Web HTML Live Update When you preview your web gallery in Lightroom, Lightroom opens a web browser which runs independently of the main application. If, during the preview, you make changes to the gallery parameters
  • Adobe 65007312 | Programming Guide - Page 140
    , a user might change a model variable using the control panel. In order to reflect the change in the previewed page, the Lightroom browser normally needs to reload the page. Lightroom clears all cached copies of the page, tells the browser to reload, and builds new HTML and CSS files in response to
  • Adobe 65007312 | Programming Guide - Page 141
    what behavior to use by returning one of these strings: X invalidateOldHTML: The browser cache is cleared, and all of the HTML pages in Lightroom's page cache are cleared. The exported JPEGs remain unchanged. The reload is deferred until the user navigates away from the currently previewed page
  • Adobe 65007312 | Programming Guide - Page 142
    reloads the browser as often as it can while the mouse is dragged. Example live-update implementation The Lightroom SDK includes the source code for the default HTML web engine, which includes an example implementation of document.liveUpdate() in the file live_update.js. To
  • Adobe 65007312 | Programming Guide - Page 143
    matches the given id value. setActiveImageSize = function( size ) Tells Lightroom which of the sizes is currently being displayed on screen. Use for the given dot-separated key path. fetchURL = function( url, callbackName ) Downloads the contents of a given URL and returns it as a string. This is
  • Adobe 65007312 | Programming Guide - Page 144
    CHAPTER 6: Writing a Web-engine Plug-in Web HTML Live Update 144 You can add in-place editing functionality to any node containing text by adding code like this to your HTML: onclick="clickTarget( this, 'target_property' );" For example:
  • Adobe 65007312 | Programming Guide - Page 145
    7 Using ZStrings for Localization ZStrings are an Adobe convention for defining localization strings. You identify a string according to its usage in the user interface, and specify it in the ZString format. This enables Lightroom to look up language-specific versions of the string to display to
  • Adobe 65007312 | Programming Guide - Page 146
    CHAPTER 7: Using ZStrings for Localization ZString format 146 Like any Lua string, ZStrings can be enclosed in single or double quotes. For example: LOC "$$$/MyPlugin/Dialogs/Description/sectionName=Description" LOC '$$$/MyPlugin/Dialogs/Description/Title=Document Title:' ZString characters and
  • Adobe 65007312 | Programming Guide - Page 147
    returns the default string provided with the ZString. You can use the LOC function anywhere you specify display strings: X In the title for your Export Service Provider X In the title for menu items that you add X In the title and value properties of UI elements Any of these properties can take
  • Adobe 65007312 | Programming Guide - Page 148
    must located be in the top plug-in folder, with the Info.lua file. Lightroom automatically selects the appropriate translation file based on the current language in use for the application. Lightroom performs ZString translation when it creates the object containing the string. When the LOC function
  • Adobe 65007312 | Programming Guide - Page 149
    MyPlugin/Image/Title=Titel" "$$$/MyPlugin/Image/Quality=Qualität" "$$$/MyPlugin/Image/View=Ansicht" "$$$/MyPlugin/Enabled=Aktiviert" Supported languages These languages are supported: Language German English Spanish French Italian Japanese Korean Dutch Portuguese Swedish Chinese, simplified Chinese
  • Adobe 65007312 | Programming Guide - Page 150
    Lightroom SDK" on page 8). The plug-in script files are written using the Lua scripting language which have the file extension .lua. Each section in this chapter lists the program files and support of these samples is an Export Service Provider, extending Lightroom's Export dialog by adding a new
  • Adobe 65007312 | Programming Guide - Page 151
    Information file that describes the plug-in to Lightroom. The service definition file. Defines the initialization routes and -in and guide you through exporting images to an FTP server. Bring up the FTP plug-in 1. Use the Plug-in Manager to add the plug-in, found in the Lightroom SDK samples folder
  • Adobe 65007312 | Programming Guide - Page 152
    CHAPTER 8: SDK Sample Plug-ins The FTP Upload sample plug-in 152 Configure the connection 1. In the FTP Server section of the Export dialog, bring up the Destination pop-up menu and choose Edit. This displays the configuration dialog for the FTP server settings.
  • Adobe 65007312 | Programming Guide - Page 153
    sample plug-in 153 2. Fill out the configuration section: Z Server: Enter the name of the FTP server you wish to connect to, for example: myftpserver.adobe.com. You do not need to enter the protocol. Z Username: Enter the username you use to log into your FTP Server. Z Password: Enter the password
  • Adobe 65007312 | Programming Guide - Page 154
    , bring up the Preset popup and select Save Current Settings as new Preset. In the resulting dialog, enter a name for your preset and click Create. Lightroom connects to your FTP server and displays a Browse dialog. 4. Click OK. This returns you to the Export dialog. 5. If you want to upload your
  • Adobe 65007312 | Programming Guide - Page 155
    .html Flickr plug-in walkthrough These steps guide you through authorizing Lightroom with a Flickr account and publishing images. 1. In the Lightroom Library module, make sure the Publish Services panel is open, and shows the Flickr service. Z If the Flickr service does not appear, go to the Plug
  • Adobe 65007312 | Programming Guide - Page 156
    service is selected, and adds new sections to the dialog. Notice that is also adds a status message at the bottom, next to the Plug-in Manager button. 4. In the Flickr Account section of the Publishing Manager, click Log In. This invokes a dialog that informs you that you must authorize Lightroom
  • Adobe 65007312 | Programming Guide - Page 157
    has changed to Switch User. 7. Click Save to establish the new publish service. Z Notice that the new publish service now appears under the Flickr service in the Publish Services panel. Add photos and publish the collection Lightroom has created a default collection named "Photostream" in your new
  • Adobe 65007312 | Programming Guide - Page 158
    them. To do this, click Publish at the bottom left corner of the screen. 4. As it does during an export operation, Lightroom renders the photos and uploads them to the service. A progress bar in the top left corner of the screen shows the status of the publish operation. 5. Once the process is
  • Adobe 65007312 | Programming Guide - Page 159
    (in this case, Flickr). If you make changes to photos that have already been published or delete them, Lightroom attempts to mirror those changes on the service. To see this: 1. Select one of your photos that has been published and make a simple change to it (for example, rotate the photo 90°). You
  • Adobe 65007312 | Programming Guide - Page 160
    CHAPTER 8: SDK Sample Plug-ins The Flickr plug-in 160 Get feedback from viewers Lightroom's Publish feature allows you to retrieve selected feedback from a web service and display it in Lightroom's Comments panel. To see this: 1. Select one of your photos that has been published. 2. Right click or
  • Adobe 65007312 | Programming Guide - Page 161
    fields defined in the previous sample. Custom metadata sample walkthrough 1. Use the Plug-in Manager to add the plug-in, found in the Lightroom SDK samples folder: LR_SDK/Sample Plugins/custommetadatasample.lrdevplugin 2. In the Metadata panel of the Library module, open the menu at the top left
  • Adobe 65007312 | Programming Guide - Page 162
    you set the Display Image value to Yes: Metadata filter sample 1. Use the Plug-in Manager to add the plug-in, found in the Lightroom SDK samples folder: LR_SDK/Sample Plugins/metaexportfilter.lrdevplugin. 2. Select some photos in the Library module, noting the Title metadata values for one or more
  • Adobe 65007312 | Programming Guide - Page 163
    CHAPTER 8: SDK Sample Plug-ins 3. Open the Export dialog by choosing File > Export. Metadata and filtering samples 163 4. Notice the entry for this plug-in, Metadata Post Process, in the Post-Process Actions panel. 5. Open the entry by clicking the gray arrow at the left, select the action, click
  • Adobe 65007312 | Programming Guide - Page 164
    which excludes files with matching metadata from the export operation. This illustrates how to combine a simple exclusion filter with the external post-processing Manager to add the plug-ins, found in the Lightroom SDK samples folders: LR_SDK/Sample Plugins/creatorfilter.lrdevplugin and LR_SDK
  • Adobe 65007312 | Programming Guide - Page 165
    CHAPTER 8: SDK Sample Plug-ins 2. Select some photos in the Library module. 3. Open the Export dialog by choosing File > Export. Post-processing samples 165 Notice the entry for these plug-ins, Creator External Tool and Language External Tool, in the Post-Process Actions panel. Each plug-in
  • Adobe 65007312 | Programming Guide - Page 166
    metadata and observe the result. Z Any photos you filtered out based on Lightroom metadata values should not have been exported. Z The XMP metadata should reflect how the architecture differs from that of a standard plug-in. It illustrates all of the plug-in parts by creating a simple HTML gallery.
  • Adobe 65007312 | Programming Guide - Page 167
    CHAPTER 8: SDK Sample Plug-ins Web engine sample 167 3. Select the web engine defined by this plug-in that appears in the Engine list: 4. The gallery preview appears, showing a filmstrip of small images on one side and a larger version of the selected image on the right.
  • Adobe 65007312 | Programming Guide - Page 168
    Lightroom. The concepts and techniques are explained in more detail in Chapter 3, "Creating Export and Publish Services ." X Additional features you can add using the same framework are demonstrated in Chapter 10 LrToolkitIdentifier = 'com.adobe.lightroom.sdk.helloworld', } 3. Add another entry
  • Adobe 65007312 | Programming Guide - Page 169
    scripts Each menu item, when selected, runs the associated service script, which defines that command's behavior. In this case, we will define both of these commands to display dialog boxes. The Lightroom SDK provides the facility to display both predefined and customized dialogs using the LrDialogs
  • Adobe 65007312 | Programming Guide - Page 170
    item that we added to the Library menu creates a custom dialog, which required quite a bit more programming. These steps describe how to write the service script that defines the program data and custom interface elements, ties the data to the UI elements, and displays them in a custom dialog box
  • Adobe 65007312 | Programming Guide - Page 171
    .makePropertyTable( context ) -- create bound table props.isChecked = false -- add a property key and initial value -- create view hierarchy Create UI elements The Lightroom SDK also provides the LrView class and namespace which allows you to create custom dialog elements. You need to populate the
  • Adobe 65007312 | Programming Guide - Page 172
    Getting Started: A Tutorial Example Displaying a custom dialog 172 10. Use LrDialogs.presentModalDialog() to display the custom dialog. The plug-in and see how the menu items bring up the two dialogs: 1. In Lightroom, choose File > Plug-in Manager to show the Plug-in Manager dialog. Z If you have
  • Adobe 65007312 | Programming Guide - Page 173
    CHAPTER 9: Getting Started: A Tutorial Example Transforming data 173 Transforming data The very simple binding we created for the checkbox allows you to set and clear a data value by selected or deselecting the checkbox button. To show a more complex relationship between the UI and the data, we
  • Adobe 65007312 | Programming Guide - Page 174
    the function when the script runs, replace the call to showCustomDialog() at the bottom of the script with a call to the new function: MyHWLibraryItem.showCustomDialogWithTransform() 10. Save your changes to the file.
  • Adobe 65007312 | Programming Guide - Page 175
    CHAPTER 9: Getting Started: A Tutorial Example Binding to multiple keys 175 Run the plug-in Use these steps to run the plug-in and test the dialog: 1. Reload the plug-in, as described in step 1 on page 172. 2. Choose Library > Plug-in Extras > Hello World Custom Dialog to show the custom modal
  • Adobe 65007312 | Programming Guide - Page 176
    CHAPTER 9: Getting Started: A Tutorial Example Binding to multiple keys 176 2. In the body of this function, add code to create the function-context call you need for the property table: -- body of show-dialog function LrFunctionContext.callWithContext( "showCustomDialogWithMultipleBind", function
  • Adobe 65007312 | Programming Guide - Page 177
    CHAPTER 9: Getting Started: A Tutorial Example Binding to multiple keys 177 } }, }, value = LrView.bind( "sliderTwo" ), width_in_digits = 7 f:group_box { fill_horizontal = 1, title = "Both Values", font = "", f:edit_field{ place_horizontal = 0.5, value = LrView.bind { -- Supply a table
  • Adobe 65007312 | Programming Guide - Page 178
    changes, this function is automatically invoked; the return value becomes the result of the binding, and thus the value of the edit box. 10. Use LrDialogs.presentModalDialog() to display the new custom dialog, and call it when the script is run: local result = LrDialogs.presentModalDialog { title
  • Adobe 65007312 | Programming Guide - Page 179
    CHAPTER 9: Getting Started: A Tutorial Example Binding to multiple keys 179 3. Move the sliders and notice how the text below them changes, reflecting the current value for each numeric property, and how the sum of the two values is displayed in the "Both Values" box. 4. Dismiss the dialog with OK
  • Adobe 65007312 | Programming Guide - Page 180
    CHAPTER 9: Getting Started: A Tutorial Example Adding a data observer 180 Adding a data observer The most flexible way of connecting to your data is to create an observer for the property table; this is an independent object that is notified of changes in the table, and can take any action in
  • Adobe 65007312 | Programming Guide - Page 181
    CHAPTER 9: Getting Started: A Tutorial Example Adding a data observer 181 Create an observer for a data property To make the text dynamic, we are going to add an observer for the props.myObservedString key. The observer is notified whenever the observed property changes; we will tell it to update
  • Adobe 65007312 | Programming Guide - Page 182
    other controls showValue_st.text_color = LrColor( 0, 0, 0 ) -- make text black props.myObservedString = updateField.value -- reset data value -- from current entered value end }, 10. Use LrDialogs.presentModalDialog() to display the new custom dialog, and call it when the script is run: local result
  • Adobe 65007312 | Programming Guide - Page 183
    Dismiss the dialog with OK or Cancel. Debugging your plug-in The Lightroom SDK does not supply a development environment for you to debug your application, such as one of these tools: X WinDbg - available for download from http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx X Microsoft
  • Adobe 65007312 | Programming Guide - Page 184
    in if necessary. Viewing trace information using log files These steps describe how to view debugging trace information using a text editor: 1. Start Lightroom. 2. Make sure your plug-in is configured to write debugging information to a log file, as described above: local LrLogger = import 'LrLogger
  • Adobe 65007312 | Programming Guide - Page 185
    Started: A Tutorial Example Debugging your plug-in 185 4. In the Attach to Process dialog, scroll through the processes and look for lightroom.exe. 5. Select lightroom.exe and click OK. A console window appears in WinDbg, and the Lightroom application is blocked. 6. In WinDbg, choose Debug > Go.
  • Adobe 65007312 | Programming Guide - Page 186
    to see the trace information being written as you use the plug-in. Debugging in Mac OS Console 1. Start Lightroom 2. Start Console. The default location is Applications > Utilities > Console. 3. In Lightroom, run the Hello World plug-in (see "Run the plug-in" on page 182). 4. View the console to see
  • Adobe 65007312 | Programming Guide - Page 187
    10 Defining Metadata: A Walkthrough This chapter shows how a plug-in can define metadata fields that Lightroom can display along with standard metadata for photos, and which you can use as a private data model for plug-in processing. It also illustrates how the private data can be used to customize
  • Adobe 65007312 | Programming Guide - Page 188
    CHAPTER 10: Defining Metadata: A Walkthrough Adding custom metadata 188 5. The }, { id = 'myString', -- add properties }, }, 7. To make this new field available to edit within the Lightroom Metadata panel, we need to add a title and data type: metadataFieldsForPhotos = { { id = 'siteId', }, {
  • Adobe 65007312 | Programming Guide - Page 189
    -value data type. { id = 'myboolean', title = LOC "$$$/MyMetadataSample/Fields/Display=My Boolean", dataType = 'enum', values = { -- add valid-value entries }, }, 10. Now we will limit the possible values to the strings "true" and "false". { id = 'myboolean', title = LOC "$$$/MyMetadataSample/Fields
  • Adobe 65007312 | Programming Guide - Page 190
    CHAPTER 10: Defining Metadata: A Walkthrough Using the plug-in 190 items = { -- add item in metadata for Lightroom: items = { -- add item entries { 'com.adobe.label', label = LOC "$$$/Metadata/OrigLabel=Standard Metadata" }, 'com.adobe.filename', 'com.adobe.folder', 'com.adobe.separator', }, This
  • Adobe 65007312 | Programming Guide - Page 191
    CHAPTER 10: Defining Metadata: A Walkthrough Using the plug-in 191 6. Select the My Metadata tagset. The Metadata panel should display the filename and folder fields in a section
  • Adobe 65007312 | Programming Guide - Page 192
    CHAPTER 10: Defining Metadata: A Walkthrough Customizing the Plug-in Manager 192 Customizing the Plug-in Manager You plug-in can define a customized section for the Plug-in
  • Adobe 65007312 | Programming Guide - Page 193
    CHAPTER 10: Defining Metadata: A Walkthrough Customizing the Plug-in Manager 193 5. The and edit it to add these variables: _G.currentDisplayImage = "no" _G.pluginID = "com.adobe.lightroom.sdk.metadata.custommetadatasample" _G.URL = "http://www.mycompany.com" The _G prefix here indicates that
  • Adobe 65007312 | Programming Guide - Page 194
    10: Defining Metadata: A Walkthrough Customizing the Plug-in Manager 194 title = _G.currentDisplayImage, fill_horizontal = 1 end 8. Reload and run the plug-in again, as described in "Using the plug-in" on page 190. When you select the plug-in, the new section appears above the standard Lightroom
  • Adobe 65007312 | Programming Guide - Page 195
    plug-in files, in the following folder according to your operating system: Z In Mac OS: userhome/Library/Application Support/Adobe/Lightroom/ Web Galleries/mySamplePlugin.lrwebengine Z In Windows: LightroomRoot\shared\webengines\mySamplePlugin.lrwebengine Add descriptive files 1. In the myWebPlugin
  • Adobe 65007312 | Programming Guide - Page 196
    content="text/html; charset=utf-8" /> My Sample Plug-in
  • Adobe 65007312 | Programming Guide - Page 197
    = 3.0, LrSdkMinimumVersion = 2.0, -- minimum SDK version required by this plug-in title = "My Sample Plug-in", id = "com.adobe.wpg.templates.mysample", galleryType = "lua", maximumGallerySize = 50000, model = { ["nonDynamic.imageBase"] = "content", ["photoSizes.thumb.height"] = 150, ["photoSizes
  • Adobe 65007312 | Programming Guide - Page 198
    we need to import this tagset into the "lr" namespace. 4. In the manifest.lrweb file, add this code at the top: importTags( "lr", "com.adobe.lightroom.default" ) AddCustomCSS { filename = 'content/custom.css', } 5. Now we can define the contents of image grid and its contents. Add this code to grid
  • Adobe 65007312 | Programming Guide - Page 199
    the corresponding large image. Add the "large" photo size 1. The data model needs to define the new photo size and its supporting parameters. In the galleryInfo.lrweb file, add these items to the model table: model = { ... ["photoSizes.thumb.metadataExportMode"] = "copyright", ["photoSizes.large
  • Adobe 65007312 | Programming Guide - Page 200
    CHAPTER 11: Web Gallery Plug-ins: A Tutorial Example Defining a data model and functionality 200 Add link functionality 3. In the grid.html template, add a link in each photo cell of the grid that retrieves the large-version page corresponding to the thumbnail in that cell:
  • Adobe 65007312 | Programming Guide - Page 201
    CHAPTER 11: Web Gallery Plug-ins: A Tutorial Example Customizing the Web Gallery UI 201 6. After the pagination code, add the link that actually retrieves the large image to be shown:
  • Adobe 65007312 | Programming Guide - Page 202
    This is a sample implementation of the update functions and callbacks needed for Live Update. Testing the plug-in 1. Save all of your changes and restart Lightroom. 2. Select some photos. 3. Go to the Web Gallery page and select the new gallery type. 4. Place the cursor over the "MySample" text that
  • Adobe 65007312 | Programming Guide - Page 203
    CHAPTER 11: Web Gallery Plug-ins: A Tutorial Example Adding a customized tagset 203 Define the tags 1. Create a file in the plug-in folder named myExampleTags.lrweb, and edit it to define this list of sayings: local sayings = { "A dish fit for the gods - Julius Caesar, Shakespeare", "Oh, that way
  • Adobe 65007312 | Programming Guide - Page 204
    CHAPTER 11: Web Gallery Plug-ins: A Tutorial Example Adding a customized tagset 204 This associates the prefix "xmpl" with the imported tagset, the tags can be referenced as: ... 6. Finally, we need to use the tags in one of the template
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

LIGHTROOM SDK 3.0
PROGRAMMERS GUIDE