4 Replies Latest reply on Jun 27, 2011 4:51 PM by johnrellis

    Creating an LrExportSession

    sandwicense Level 1

      For my publish service plugin, when I want to create a new collection in Lightroom, I want the user to select a photo first, then right click on the publish service and click "Create Collection".  When the user finishes, Lightroom calls the publishServiceProvider.endDialogForCollectionSettings().  I want to be able to get the selected photo (which works fine) then create an export session to export it to a JPEG and upload it.  My reasoning is that the photo will be the thumbnail photo for the collection on the website.  Kind of like the thumbnail of a Facebook album. When I try executing the code, I get an internal error that says: AgExportSession: missing libraryFile argument.  What is that argument exactly and is this possible to do?


      This is my code so far:

      function publishServiceProvider.endDialogForCollectionSettings(publishSettings, info)
           -- Reflect the changes on the server
           LrTasks.startAsyncTask( function()
           local catalog  = LrApplication.activeCatalog()
           local selectedPhoto = catalog:getTargetPhoto()
           local exportSettings = {
                          LR_format = "JPEG",
                          LR_export_colorSpace = "sRGB",
                          LR_jpeg_quality = 100,
                          LR_jpeg_useLimitSize = false,
                          LR_size_doConstrain = true,
                          LR_size_maxHeight = 900,
                          LR_size_maxWidth = 900,
                          LR_size_units = "pixels",
                          LR_size_resizeType = "wh",
                          LR_size_resolution = 72,
                          LR_size_resolutionUnits = "inch",
                          LR_outputSharpeningOn = false,
                          LR_minimizeEmbeddedMetadata = true,
                          LR_useWatermark = false,
                          LR_export_destinationType = "desktop",
                          LR_collisionHandling = "ask",
                          LR_extensionCase = "lowercase",
                          LR_tokens = "{{image_originalName}}",
           local params =  {
                                    photosToExport = { selectedPhoto  },
                                    exportSettings = { exportSettings }
           local exportSession = LrExportSession(params)
           local args = {}
           args.content = {
                                    { name = 'new_album_name',     value = albumName },
                                    { name = 'album_title',     value = photoTitle },
                                    { name = 'album_desc',          value = photoDescription },
                                    { name = 'image_file',
                                      fileName          = fileName,
                                      filePath          = imagePath,
                                      contentType     = 'multipart/form-data'
                local result = PublisherAPI.callRestMethod('postmultipart', 'create_new_album', args)
           end )

        • 1. Re: Creating an LrExportSession
          areohbee Level 6

          I think you have an extra set of braces around the export settings. i.e. try:


           local params =  {
                                        photosToExport = { selectedPhoto  },
                                        exportSettings = exportSettings

          instead. No?

          • 2. Re: Creating an LrExportSession
            sandwicense Level 1

            I didn't notice that, but it doesn't solve the problem.  That might cause another error down the line, so I fixed it.


            Edit 1:


            It must have something to do with the photosToExport parameter because when I delete the selectedPhoto variable and just pass in an empty table, the same error occurs.


            Do you know what "Ag" in AgExportSession stands for?


            Edit 2:


            Solved it with a little bit of trial and error:


            When getting the targetPhoto the line should look like this (added the curly braces):


            local selectedPhoto = { catalog:getTargetPhoto() }


            If you wanted to get all the target photos, then just remove the curly braces:


            local selectedPhotos = catalog:getTargetPhotos()


            Message was edited by: sandwicense


            Message was edited by: sandwicense

            • 3. Re: Creating an LrExportSession
              areohbee Level 6

              Congrats. I dont know what Ag stands for but its the prefix of many lrcat database tables and also is the prefix of some lightroom variables.

              • 4. Re: Creating an LrExportSession
                johnrellis Most Valuable Participant

                Ag is the chemical symbol for silver.  LR's internal namespaces start with "Ag", a reference to the silver in black-and-white film.  See this thread: