20 Replies Latest reply on Jun 13, 2012 2:02 PM by sandwicense

    Two different resolutions of the same image in Export plugin?

      Hello all,

      I would like to write a export plug in, which is able to produce two different resolution for all rendered photos. I would like to use this, for up loading images and their thumbs for a web-gallery ( I don't need to create html pages, so I wouldn't like to use the web-engine plug in). Up to now I didn't find a way, how to start the rendering processes a second time out of the export plug in. Does there exist some tricks to accomplish that?

      best regards
      Bernie
        • 1. Re: Two different resolutions of the same image in Export plugin?
          escouten Adobe Employee
          Your plug-in should be able to spin up a second LrExportSession and wait for the corresponding images to be rendered.
          • 2. Re: Two different resolutions of the same image in Export plugin?
            Level 1
            Hello

            So this could be a possible way (just to confirm, that I am on the right way):

            1) wait until first rendering finishes
            2) get the list of photos, that was used for the first rendering
            3) change the exportSettings to confirm the new image scaling
            4) use LrExportSession to create a second rendering process
            5) wait until second rendering finishes

            If I use the ftp_upload export plugin as a starting point, would the function FtpUploadTask.processRenderedPhotos be a good place to insert all the things?

            best regards
            Bernie
            • 3. Re: Two different resolutions of the same image in Export plugin?
              escouten Adobe Employee
              Yes, that's what I had in mind.
              • 4. Re: Two different resolutions of the same image in Export plugin?
                Level 1
                Eric - Is there any practical limit to the number of LrExportSessions one could create? I've started work again on this (http://www.adobeforums.com/webx/.59b6156c) and I'd want to create a rendering for each zoom level - sometimes that's as many as 8 per image.

                Thanks,
                Dave
                • 5. Re: Two different resolutions of the same image in Export plugin?
                  (nhok-)
                  Hello Eric,

                  I am now at the point, the use LrExportSession for exporting the thumbnails images in a different resolution. Unfortunately I have some problem I don't understand.

                  As an starting example I use the SamplePlugin Ftp-Upload. There I insert in the function FtpUploadTask.processRenderedPhotos after the Rendition of all Photos following code:

                  local thbExportParams = exportContext.propertyTable
                  thbExportParams.LR_tokenCustomString = "sm_{Dateiname}"
                  thbExportParams.LR_size_maxHeight = 200
                  thbExportParams.LR_size_maxWidth = 200

                  local expPhotos = {}
                  local i = 1
                  for photo in exportSession:photosToExport() do
                  expPhotos[i] = photo
                  i = i + 1
                  end
                  myLogger:trace("i = " .. i)

                  myLogger:trace("Create thbExportSession")
                  local thbExportSession = LrExportSession({ photosToExport = expPhotos, exportSettings = thbExportParams, })
                  myLogger:trace("Created thbExportSession")

                  I do then get an error message, that there is a missing Export-Setting
                  LR_export_destinationPathPrefix.

                  I use a standard tempFolder, so I think, this shouldn't make any problems, even if I set the parameter LR_export_destinationPathPrefix to "c:\\" I get the same message.
                  As I didn't found any example using LrExportSession, I would like to ask, if the calling/syntax I use is correct?

                  best regards
                  Bernie
                  • 6. Re: Two different resolutions of the same image in Export plugin?
                    escouten Adobe Employee
                    @Dave: Off the top of my head, no. That said, I don't think we've done any stress testing of multiple simultaneous exports. I'd recommend keeping it in the single digits or so.
                    • 7. Re: Two different resolutions of the same image in Export plugin?
                      escouten Adobe Employee
                      @Bernie: The LrExportSession that you are creating here, programatically, is not an FTP upload, it's an export to file. That's because you didn't specify an export service provider in the params to LrExportSession, so it filled in the default.

                      It also filled in the default setting for export location, which is "specific folder", but it doesn't have a folder to export to.

                      You must either add LR_export_destinationType = "tempFolder" or LR_export_destinationPathPrefix = "C:\\path\\to\\somewhere".

                      Hope this helps.
                      • 8. Re: Two different resolutions of the same image in Export plugin?
                        escouten Adobe Employee
                        @Bernie: Please disregard my previous message. Just a few minutes ago, I identified a bug in LrExportSession that is probably to blame for this message.

                        The bug is this: If the exportSettings table you pass in is an observable table, as is the case in your code because you used exportContext.propertyTable, we fail to read the settings out of that table correctly.

                        As far as I know, this bug is present in all shipping versions of Lightroom (1.3 through 2.2).

                        You'll see a fix in an upcoming version of Lightroom. In the meantime, you can work around this by making a non-observable table out of your settings. This would look something like the following:

                        local mySettingsCopy = {}
                        for k, v in LrObservations.pairs( exportContext.propertyTable ) do
                        mySettingsCopy[ k ] = v
                        end

                        -- (insert your code to modify the settings )

                        local thbExportSession = LrExportSession({ photosToExport = expPhotos, exportSettings = mySettingsCopy, })

                        Very sorry for the confusion. Hope this updated bit of code helps.
                        • 9. Re: Two different resolutions of the same image in Export plugin?
                          (nhok-) Level 1
                          Hello Eric,

                          I try the following code-sample inside the ftp-upload-plugin

                          local exportSettings
                          exportSettings = { }

                          exportSettings = exportContext.propertyTable
                          exportSettings.LR_tokenCustomString = "sm_{Dateiname}"
                          exportSettings.LR_size_maxHeight = 200
                          exportSettings.LR_size_maxWidth = 200
                          exportSettings.LR_export_destinationType = "tempFolder"
                          exportSettings.LR_export_destinationPathPrefix = "c:\\"

                          local photosToExport = { }
                          photosToExport = { }

                          local i = 1
                          for photo in exportSession:photosToExport() do
                          photosToExport[i] = photo
                          i = i + 1
                          end
                          myLogger:trace("i = " .. i)
                          local params = { }

                          params = { photosToExport, exportSettings }
                          --params = { photosToExport=photosToExport, exportSettings=exportSettings }

                          myLogger:trace("Create thbExportSession")
                          local thbExportSession = LrExportSession( params )

                          As I am not sure, if I use the correct syntax for LrExportSession Params table I tried two variations of the table params, each time both index (LR_export_destinationType and LR_export_destinationPathPrefix I set with the value seem above in the code. But I get the error, LR_export_destinationPathPrefix must be defined...

                          Do you know any help?

                          best regards
                          Bernie
                          • 10. Re: Two different resolutions of the same image in Export plugin?
                            (nhok-) Level 1
                            Hello Eric,

                            I overseen during writing my last message your post number 8, so I will try your suggestion right now

                            best regards
                            Bernie
                            • 11. Re: Two different resolutions of the same image in Export plugin?
                              (nhok-) Level 1
                              Hello Eric,

                              I tried you last suggestions, but get an error on LrObservations.
                              Is the LrObservations a standard sdk space? It seems not to be mentioned in die LR SDK Reference

                              best regards
                              Bernhard
                              • 12. Re: Two different resolutions of the same image in Export plugin?
                                (nhok-) Level 1
                                Hello Eric,

                                so I tried the hard way, and build up the exportsettings from scratch, and...

                                now it works! Thanks for finding the ls sdk bug

                                Now I have one further question / problem.

                                As I said, I after building the the exportSettings from scratch everything works fine but the renaming of the filenames

                                The first thing I tried is to use the call
                                ftpInstance:putFile( pathOrMessage, "sm" .. filename )
                                to put the file on the server, but allthough the filename is extend, the putFile don't changes the name, on the server the name is like pathOrMessage

                                Then I also tried to use exportSettigs.LR_tokens = "sm_{{image_name}}", like i saw in the saved export Preference file, but this changed also nothing on the filename.

                                Does there exist a easy way to change the names

                                best regards
                                Bernie
                                • 13. Re: Two different resolutions of the same image in Export plugin?
                                  (Kamal_Sharif) Level 1
                                  Hello Bernie;
                                  I am having a similar situation here. I am trying to create an application specific project folder plus two scaling of the image. It does not make sense for me to let users change the destination type to anything other than my application directory. So, I am trying to hide the section and set the properties I want in method like this

                                  function DefaultExportSettings(propertyTable)
                                  propertyTable.LR_export_destinationType='spedificFolder'
                                  propertyTable.LR_export_useSubfolder=true
                                  propertyTable.LR_export_destinationPathPrefix=_G.data.exportFolder
                                  propertyTable.LR_export_destinationPathSuffix= _G.data.projectName
                                  end

                                  However, whether or not I hide the section, the export fails telling me that it is missing destinationPathPrefix property. The error message is:
                                  Unable to Export:
                                  An internal error has occurred: export settings are missing the LR_export_destinationPathPrefix

                                  Any ideas? Your time is appreciated.
                                  Regards
                                  • 14. Re: Two different resolutions of the same image in Export plugin?
                                    (Kamal_Sharif) Level 1
                                    Hi Eric;
                                    I just read your post that there is a bug. I am new to Lua and Lr, and am getting really lost. I appreciate you give me an idea on how to do this:
                                    Hid the file location from user or make it read-only.
                                    Set the values to specificFolder and a value that I have from my application sent over in an xml file.
                                    That way, the default export of LR works for me and I only need to create a post process action to create a scaled down version of the image.
                                    Thank you so much.
                                    Kamal
                                    • 15. Re: Two different resolutions of the same image in Export plugin?
                                      escouten Adobe Employee
                                      Kamal, in the SDK guide on about page 47(*) there is a section titled "Restricting existing export functionality", which describes how you can remove some of the sections from the export dialog.

                                      To hide the export location panel, you can include the line

                                      hideSection = { 'exportLocation' },

                                      in your export service provider definition.

                                      On about page 35, there's a section titled "Deciding how the photos should be rendered" which describes how you can impose your own settings for file location (or anything else) before Lightroom starts rendering the photos.

                                      Hope this helps.

                                      (* I'm looking at a slightly different version of the guide, which is why my page numbers might be off by one or two.)
                                      • 16. Re: Two different resolutions of the same image in Export plugin?
                                        (nhok-) Level 1
                                        Hello Kamal,

                                        I have solved this problem in creating a exportSettings table from scratch (you will find the parameter names in the LR SDK document (pdf)). After this, everything works fine

                                        best regards
                                        Bernie
                                        • 17. Re: Two different resolutions of the same image in Export plugin?
                                          (Kamal_Sharif) Level 1
                                          Hello Bernie;
                                          Thanks for the tip. It is good to know that the issue has been solved.
                                          I have tried to hide the section and it is working. But after doing that, even after setting them from the table you mentioned, the export fails with an error message that the settings is missing LR_export_destinationPathPrefix. I now I have set it and in the processRenderedPhotoes, I output the value, it exists. I am setting these values:
                                          LR_export_destinationType, LR_export_destinationPathPrefix, LR_export_useSubfolder.

                                          Can you send me some sample code of how you created the settings object from scratch, and more importantly, where to put that code. I would assume that all that code will go into start dialog of the plugin, but not sure.

                                          Regards
                                          Kamal
                                          • 18. Re: Two different resolutions of the same image in Export plugin?
                                            larzKl

                                            Hi Bernie,

                                             

                                            I'm trying to achieve basically the same thing as you did: exporting two different versions of the same image, one full sized, one thumbnail. (eventually I hope to turn this into a lightweight blog editor, uploading photos to a serendipity blog and adding some basic text - but I'm still struggling to get the mere basics working).

                                             

                                            Could you post a snippet of your working code for multiple uploads?

                                             

                                            Does LR 2.6 still have issues with ExportSettings tables? It seems to, since I keep getting error messages saying 'params table must have exportSettings", although I would have thought my code does exactly that. Is it still necessary to create the table from scratch? If so, I'm struggling with the code suggested above, it uses LrObservations, which seems not to be part of the SDK and I can't find it documented anywhere.

                                             

                                            Kind regards

                                             

                                            Lars

                                            • 19. Re: Two different resolutions of the same image in Export plugin?
                                              Allen Gambrell Level 1

                                              Was the bug fixed in Lightroom 3 SDK, because I am running into the same error again.

                                               

                                              It says "export settings are missing the LR_export_destinationPathPrefix" whenever I set the export to hide the location.

                                              • 20. Re: Two different resolutions of the same image in Export plugin?
                                                sandwicense

                                                I am having the same problem in the with LR4.

                                                 

                                                When  LR_export_destinationType = "tempFolder", I get an error stating that LR_export_destinationPathPrefix has not been set.

                                                If I set LR_export_destinationType = "desktop", it works fine.

                                                 

                                                Another question I had was when I set it to "desktop", the photos are exported to a folder called "Untitled Export". How can I change the folder name?

                                                 

                                                Here is a snipet of my code...

                                                 

                                                LrTasks.startAsyncTask( function()

                                                 

                                                                                        local progressScope = LrProgressScope({title = 'Creating New Collection'})

                                                 

                                                                                        progressScope:setCaption('Preparing to render thumbnail.')

                                                 

                                                                                        local catalog = LrApplication.activeCatalog()

                                                 

                                                                                        local targetPhoto = 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 = 5000,

                                                                                                                                                              LR_size_maxWidth = 5000,

                                                                                                                                                              LR_size_units = "pixels",

                                                                                                                                                              LR_size_resizeType = "wh",

                                                                                                                                                              LR_size_resolution = 72,

                                                                                                                                                              LR_size_resolutionUnits = "inch",

                                                                                                                                                              LR_size_doNotEnlarge = true,

                                                                                                                                                              LR_outputSharpeningOn = false,

                                                                                                                                                              LR_minimizeEmbeddedMetadata = true,

                                                                                                                                                              LR_useWatermark = false,

                                                                                                                                                              LR_export_destinationType = "tempFolder",

                                                                                                                                                              LR_collisionHandling = "overwrite",

                                                                                                                                                              LR_extensionCase = "lowercase",

                                                                                                                                                              LR_tokenCustomString = 'export-',

                                                                                                                                                              LR_renamingTokensOn = true,

                                                                                                                                                              LR_tokens = "{{custom_token}}{{image_originalName}}",

                                                                                                                                             }

                                                 

                                                                                        local exportParams = {

                                                                                                                                                    photosToExport = {targetPhoto},

                                                                                                                                                    exportSettings = exportSettings

                                                                                                                                           }

                                                 

                                                                                        local exportSession = LrExportSession( exportParams )