3 Replies Latest reply on Sep 3, 2009 3:24 PM by escouten

    Modifying LR_tokenCustomString in Post-Process

    JW Stephenson Level 4

      I have a post-process modeled after the sample plug-in called CreatorExternalToolfilterProvider.  It is not complicated but I did want to insure that some of the settings that may have been selected in the export are compatible with my plug-in, specifically LR_format (limit to TIFF and JPEG) and LR_tokenCustomString (change to specifically named file preset or specify one outright).

       

      Based on the manual and the sample plug-in, it seems that the best place to accomplish this is with the renditionOptions dialog first encountered after the postProcessRenderedPhotos function is called.

       

      For testing, the export routine selected a template called "Scan Processed" which has the following underlying preset code:

      s = {

           deflated = {

                {

                     "",

                     {

                          value = "image_name",

                     },

                     "_PR",

                     name = "Scan Processed",

                     presetType = "Naming",

                     },

                "AgTokenPresets",

                "restoreTokenFromArchivedState",

           },

           id = "9324F0EF-9FCC-4791-A390-2688AFD2789F",

           internalName = "Scan Processed",

           title = "Scan Processed",

           type = "Naming_Tokens",

           version = 0,

      }

       

      But I want to ensure the extension is instead "{FileName}_JWS" for exampple.

       

      The sample code is:

           function CreatorExternalToolFilterProvider.postProcessRenderedPhotos( functionContext, filterContext )

       

           local renditionOptions = {

                plugin = _PLUGIN,

                renditionsToSatisfy = filterContext.renditionsToSatisfy,

                filterSettings = function( renditionToSatisfy, exportSettings )

                -- This hook function gives you the opportunity to change the render

                -- settings for each photo before Lightroom renders it.

           end,

           }

       

      My attempt at using this was:

           local renditionOptions = {

                plugin = _PLUGIN,

                renditionsToSatisfy = filterContext.renditionsToSatisfy,

                filterSettings = function( renditionToSatisfy, exportSettings )

                exportSettings.LR_tokenCustomString = "{FileName}_JWS"

                end,

           }

       

      It simply ignores my attempt to change the LR_tokenCustomString.  So I assumed I simply don't know how to access that particular data set.  So I thought I would put in a dialog box to see what was in that table/variable/object.  I replaced the assignment code with the following:

           LrDialogs.message("Debug Stuff",exportSettings.LR_tokenCustomString)

       

      Up pops the dialog box but it is blank, implying the LR_tokenCustomString is nil.

       

      I tried many of the other Lightroom built-in property keys from the manual pages 50-51 and with this dialog box all I tried pulled up the appropriately expected values.

       

      So ... the question is (finally) is there a special way to access LR_tokenCustomString and more importantly, a way to manipulate it via this "filterSettings" routine?

       

      Thanks!

       

      Jeff

       

        • 1. Re: Modifying LR_tokenCustomString in Post-Process
          escouten Adobe Employee

          As a post-processing filter, your options are relatively limited. You can choose whether or not to render a photo and you can modify the photo in place (i.e. to add a watermark or change metadata). Aside from vetoing the request, you are not allowed to modify what the destination plug-in has requested (i.e. you can't change file type or file name).

           

          Is it possible, in your case, to move this functionality into a destination plug-in?

          • 2. Re: Modifying LR_tokenCustomString in Post-Process
            JW Stephenson Level 4

            Hi Eric,

             

            When you ask if it is possible to move this to a desination plug-in, I assume you are referring to an export plug-in, and yes I can but since I am not a lua or LR programming expert, that is probably more effort than I will go through for this safety feature I wish to add to this plug-in.

             

            I prefer also to keep this as a post-process as I would like to add it to a variety of types of export routines, including exporting to SmugMug which is code I cannot amend or duplicate.  The feature basically takes the rendered image, fixes a couple of EXIF items (camera, model), runs it through NeatImage if necessary and so chosen, puts it in a mirrored directory structure (if so chosen), then adds to the catalog (again, if so chosen).  The ability to change certain exportSettings would have allowed the plug-in to make sure certain settings are compatible with the post-processing, i.e., Neatimage needs either a TIFF or JPEG or it will bomb.  Oh well.

             

            Just curious, page 34 of the manual shows a post-process filter changing the file type to a TIFF file.  I actually tried that for fun and although it does indeed change the file type to a TIFF file, it leaves the extension as ".jpg".  Nothing complicated about that

             

            In any case, you have answered my question.  Thanks for the immediate response.

             

            Jeff

            • 3. Re: Modifying LR_tokenCustomString in Post-Process
              escouten Adobe Employee

              The example you referred to (page 34) is intended to be used when the post-processing filter needs to receive a different file type. It is still expected to produce the original file type when its done.

               

              The use case for this is something like Tim Armes' Mogrify plug-in, which could ask for a TIFF file and then generate a JPEG when its done applying its transformations in order to avoid introducing extra JPEG artifacts.