4 Replies Latest reply on Oct 6, 2013 4:56 PM by victorvodka

    ordinal position of images in catalog (which is the same as the filmstrip order?)

    victorvodka

      i'm using LrTasks to getAllPhotos in hopes of putting some image navigation inside my plugin module.  i can get a list of images this way and even use them for my in-plugin navigation, but the order of the images is different from the order in the Lightroom "filmstrip" (or whatever that thing at the bottom of lightroom's main window is called).  question:  how do i get the ordinal position of images in that filmstrip using the SDK/API?

        • 1. Re: ordinal position of images in catalog (which is the same as the filmstrip order?)
          areohbee Level 5

          My function for getting photos in filmstrip, for example purposes (requires Elare Plugin Framework to function):

          --- Get photos visible in filmstrip (as filtered, as stacked, ... ).
          --
          --  @usage without disturbing users's present selection.
          --
          --  @param selectedPhoto (LrPhoto, default=nil) catalog:getTargetPhoto() - in case already available in calling context.
          --  @param selectedPhotos (array of LrPhoto, default=nil) catalog:getTargetPhotos() - ditto.
          --  @param metadataCache (LrMetadata::Cache, optional) metadata cache.
          --  @param includeIfBuried (boolean, default=false) visible only? or those underneath in collapsed stacks too.
          --
          --  @return visiblePhotos (array) never nil, but may be empty (e.g. virgin catalog)
          --
          function Catalog:getVisiblePhotos( params )
              -- works in Lr3+4+5/win7; ###1 test on Mac.
              params = params or {}
              local selectedPhoto = params.selectedPhoto or catalog:getTargetPhoto()
              local selectedPhotos = params.selectedPhotos or catalog:getTargetPhotos()
              local visiblePhotos
              if selectedPhoto then
                  catalog:setSelectedPhotos( selectedPhoto, {} )
                  local allVisiblePhotos = catalog:getMultipleSelectedOrAllPhotos()
                  catalog:setSelectedPhotos( selectedPhoto, selectedPhotos )
                  --Debug.pause( #allVisiblePhotos, #selectedPhotos, #selectedPhotos == #catalog:getTargetPhotos() ) 
                  visiblePhotos = allVisiblePhotos
              else
                  visiblePhotos = selectedPhotos
              end
              if not params.includeIfBuried or #visiblePhotos == 0 then
                  return visiblePhotos
              end
              -- fall-through => include underlings.
              local cache = params.metadataCache or lrMeta:createCache{ photos=visiblePhotos, rawIds={ 'isInStackInFolder', 'stackInFolderIsCollapsed', 'stackInFolderMembers', } }
              local buriedPhotos = {}
              for i, photo in ipairs( visiblePhotos ) do
                  repeat                
                      if not cache:getRawMetadata( photo, 'isInStackInFolder' ) then
                          break
                      end
                      -- photo is in stack
                      if not cache:getRawMetadata( photo, 'stackInFolderIsCollapsed' ) then
                          break
                      end
                      -- stack is collapsed, therefore it is top of stack (actually, that is only true if source is folder - viewing collection, one could view underlings of collapsed folder stacks).
                      local stack = cache:getRawMetadata( photo, 'stackInFolderMembers' )
                      --assert( stack[1] == photo, "tos?" ) - invalid assertion (see comment above).
                      for j, stackedPhoto in ipairs(stack) do
                          if photo ~= stackedPhoto then
                              buriedPhotos[#buriedPhotos + 1] = stackedPhoto
                          end
                      end
                  until true
              end
              tab:appendArray( visiblePhotos, buriedPhotos ) -- returns promptly if no buried photos.
              return visiblePhotos
          end
          
          • 2. Re: ordinal position of images in catalog (which is the same as the filmstrip order?)
            victorvodka Level 1

            i'm using the Elare framework so it does work but it still returns a list of photos in an order that does not match the order of the filmstrip. i was wondering if that order indication (an "ordinal number" if you will) exists in the meta data somewhere.

            • 3. Re: ordinal position of images in catalog (which is the same as the filmstrip order?)
              areohbee Level 5

              I thought order was same as filmstrip, other than stack underlings which are appended to the end. I guess I don't know the answer to your question then - sorry..

               

              PS - Did you borrow the Elare framework from one of my plugins, download it from assembla, or did I send you a fresh zip copy?

               

              R

              • 4. Re: ordinal position of images in catalog (which is the same as the filmstrip order?)
                victorvodka Level 1

                Elare was part of your SQLiteroom.lrplugin which is what i am using as a guide for this project i am working on.  my project makes heavy use of a separate SQLite database (i'm actually migrating from a LAMP application -- happily the MySQL queries run almost without modification in SQLite).  i come to this from PHP/MySQL and also iOS/Objective C and the thing i find most perplexing is the heavy use of asynchronous calls to do things. i really wish i could make a database call and then immediately use the resulting data. instead i have this crazy juggling act with all these asynchronous calls whose data has to be collected and dealt with in some uncertain future (like AJAX). it's odd because it's not like Lua has to go out on the internet to get the results of these queries.