Page 1 of 1

Counting images by focal length

PostPosted: Thu Sep 05, 2019 5:01 pm
by NNN636002042127646575
Hi, does anyone know how to create a count of images by focal length, preferably also with selection/filter criteria like star rating? I'm trying to find out which focal length dominates my favourite images. I mostly use zoom lenses so the actual focal length isn't necessarily an integer value from a simple list.

The ideal output would be something like this:
Filter: [one] star

Focal length from - to count
0 - 14 20
15 - 23 138
24 - 27 345
....

Any help greatly appreciated!

Re: Counting images by focal length

PostPosted: Thu Sep 05, 2019 10:10 pm
by rapdigital
This might get you started

Code: Select all
   set focalLength to get EXIF focal length of image of current document
   set starRating to get rating of variant of current document


Exif focal length reports the mm focal length (70 mm).

Re: Counting images by focal length

PostPosted: Fri Sep 06, 2019 1:05 pm
by Eric Nepean
This works, note that the brackets are essential.

Code: Select all
 tell application "Capture One 12" to get count of (images whose EXIF focal length is "75 mm")


However, to get a count of images within a range of focal lengths you likely need to do some thing like this
Code: Select all
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Capture One 12" to set focalLenghtStringL to EXIF focal length of every image

set focalLenghtNumL to {}
set ctrFocalLengthLow to 0
set UpperThresholdFocalLengthLow to 100
repeat with thisFocalLengthString in focalLenghtStringL
   repeat with spacePtr from 1 to length of thisFocalLengthString
      if " " = text spacePtr of thisFocalLengthString then exit repeat
   end repeat
   set thisFocalLenghtNum to (text 1 thru (spacePtr - 1) of thisFocalLengthString) as real
   set end of focalLenghtNumL to thisFocalLenghtNum
   ##  Put some counters here
   if UpperThresholdFocalLengthLow > thisFocalLenghtNum then set ctrFocalLengthLow to ctrFocalLengthLow + 1
end repeat

Re: Counting images by focal length

PostPosted: Fri Sep 06, 2019 3:13 pm
by NNN636002042127646575
Thanks, I'll give that a try!

Re: Counting images by focal length

PostPosted: Sat Sep 07, 2019 1:57 am
by rapdigital
Here is another approach

Code: Select all
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

tell application "Capture One 12"
   
   set focalLength to get EXIF focal length of image of current document
   set starRating to get rating of variant of current document

end tell
set L0_24 to 0
set L25_49 to 0
set L50_74 to 0
set L75_100 to 0
set theList to {}
repeat with i from 1 to (count of focalLength)
   if item i of starRating is not 0 then
      set theList's end to item 1 of my theSplit(item i of focalLength, space)
      
   end if
end repeat

repeat with a from 1 to (count of theList)
   set itemA to item a of theList as integer
   if itemA is less than or equal to 24 then
      set L0_24 to L0_24 + 1
   end if
   if itemA < 49 and itemA > 25 then
      set L25_49 to L25_49 + 1
   end if
   if itemA < 74 and itemA > 50 then
      set L50_74 to L50_74 + 1
   end if
   if itemA < 100 and itemA > 75 then
      set L75_100 to L75_100 + 1
   end if
end repeat

display dialog "Favorite focal lengths" & return & return & "less than 24mm = " & L0_24 & return & "24mm - 49mm = " & L25_49 & return & "50mm - 74mm = " & L50_74 & return & "75mm - 100mm = " & L75_100

on theSplit(theString, theDelimiter)
   -- save delimiters to restore old settings
   set oldDelimiters to AppleScript's text item delimiters
   -- set delimiters to delimiter to be used
   set AppleScript's text item delimiters to theDelimiter
   -- create the array
   set theArray to every text item of theString
   -- restore the old setting
   set AppleScript's text item delimiters to oldDelimiters
   -- return the result
   return theArray
end theSplit


change the L0-24 ranges to suit