Counting images by focal length

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

Counting images by focal length

Postby NNN636002042127646575 » Thu Sep 05, 2019 5:01 pm

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!
NNN636002042127646575
 
Posts: 24
Joined: Mon May 30, 2016 12:23 pm

Re: Counting images by focal length

Postby rapdigital » Thu Sep 05, 2019 10:10 pm

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).
rapdigital
Certified Professional
Certified Professional
 
Posts: 185
Joined: Mon Feb 02, 2009 1:52 pm

Re: Counting images by focal length

Postby Eric Nepean » Fri Sep 06, 2019 1:05 pm

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
Eric Nepean
 
Posts: 628
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: Counting images by focal length

Postby NNN636002042127646575 » Fri Sep 06, 2019 3:13 pm

Thanks, I'll give that a try!
NNN636002042127646575
 
Posts: 24
Joined: Mon May 30, 2016 12:23 pm

Re: Counting images by focal length

Postby rapdigital » Sat Sep 07, 2019 1:57 am

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
rapdigital
Certified Professional
Certified Professional
 
Posts: 185
Joined: Mon Feb 02, 2009 1:52 pm


Return to Scripting



Who is online

Users browsing this forum: No registered users and 0 guests