workaround for setting next capture copyright metadata?

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

workaround for setting next capture copyright metadata?

Postby LPb » Mon Mar 11, 2019 1:09 am

Hi,

I'm trying to figure out a workaround to embed some copyright info into the captured files.
My goal is to have the script ask for the photographer's name and have this name embedded as copyright info in the metadata of any captures in a newly created session.
Currently it seems that is only possible for importing files into the session.
import optionsn : Settings defining all aspects of the image import process for a document. Tell the document to import in order to use these settings.
PROPERTIES
import copyright (text)

note: in the CaptureOne UI it is not possible to specify specific metadata for a next capture, only the source of metadata to be applied, which is reflected in the script library.
next capture optionsn : Settings affecting an image upon its capture in a tethered workflow.
PROPERTIES
capture metadata (default/‌copy from last/‌copy from primary/‌copy from clipboard/‌copy specific from last/‌copy specific from primary/‌copy variants from last/‌copy variants from primary) : The source of metadata to be applied.


So what I'm thinking of doing as a workaround:

-include a dummy file in the bundle
-set import copyright of import options to thePhotog
-let the script import the dummy file, either directly from the bundle resource folder or after temporarily duplicating it to the desktop
-set capture metadata of next capture options to copy from last


So here's a bit of code, with the errors I'm getting underneath
Code: Select all
set thePhotog to the text returned of (display dialog "Photographer's name" default answer "")

set theDummyFile to (path to resource "dummy.jpg")
            
tell application "Finder"
   duplicate file theDummyFile to folder (path to desktop as string) with replacing
end tell

tell application "Capture One 12"
   tell newDoc to set import copyright of import options to thePhotog as string ---->ERROR1<----
   set dummyImport to POSIX file ((path to desktop as string) & "dummy.jpg") ---->ERROR2<----
   import dummyImport
end tell

ERROR1: Can’t set «class Cico» of «class CimO» to "test name".
ERROR2: Capture One 12 got an error: Can’t get POSIX file "Macintosh HD:Users:usr1:Desktop:dummy.jpg".

Can anyone shed some light on what I might be doing wrong in this instance? Or possibly suggest a better approach?

Thanks for reading!

COv12
MacOS Mojave
LPb
 
Posts: 8
Joined: Mon Feb 09, 2015 9:31 pm
Location: Belgium

Re: workaround for setting next capture copyright metadata?

Postby Eric Nepean » Mon Mar 11, 2019 6:05 am

For the Apple script errors:

Error 1: Try using "import settings" instead of "import options"

Error 2: Try moving this line before the "Tell Block", this line has nothing to do with Capture One, but you're asking Capture One to do it.

I recently helped snother user develop a backup script after each image capture, it too stored a bit of data on disk. Some commin elements to what you are trying to acheive.

https://forum.phaseone.com/En/viewtopic.php?f=70&t=29086&p=141077&hilit=backup#p141078
Eric Nepean
 
Posts: 608
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: workaround for setting next capture copyright metadata?

Postby LPb » Tue Mar 12, 2019 10:43 pm

Eric Nepean wrote:Error 1: Try using "import settings" instead of "import options"
That works great. Thanks!

Error 2: This seemed like an obvious mistake and an easy fix. But I was still struggling.
I tried many different variations using file, alias, POSIX, as string ... no luck. Error stayed the same.
Code: Select all
set theDummyFile to path to resource "dummy.jpg"                        
tell application "Capture One 12"
   tell newDoc to import theDummyFile  ---> ERROR number -1700
end tell
Capture One 12 got an error: Can’t make alias "Macintosh HD:Users:MyUsername:MyScript.scptd:Contents:Resources:dummy.jpg" into type document.


As I was writing this post for further advice, I figured it out after re-examining the script library:
importv : Perform an image import according to what is defined in the document's import settings.
----import document
--------source text or file : The file or folder to import into the document.

Here's the correct syntax
Code: Select all
set theDummyFile to path to resource "dummy.jpg"                        
tell application "Capture One 12"
   tell newDoc to import source theDummyFile
end tell
It works now.

Thank you once again Eric, I appreciate your input!
LPb
 
Posts: 8
Joined: Mon Feb 09, 2015 9:31 pm
Location: Belgium

Re: workaround for setting next capture copyright metadata?

Postby LPb » Tue Mar 12, 2019 11:41 pm

Sooo...

After all this and some testing, I can confirm that this method in general does not work.
CO does not recognise a previously imported file as a source for using Next Capture Adjustments with Metadata: 'Copy from Last'.
Could have easily tested this before hand of course :roll:

New approach:
I have saved a metadata preset, which I plan to copy to CO's metadata presets folder at the start of the session and have the script replace text pName, YYYY, JobName and SessionName with specified input.
This way the metadata will be only a few clicks away. Still better than typing it in manually I guess.
Code: Select all
<?xml version="1.0"?>
<SL Engine="1200">
   <E K="Contact_Creator" V="pName" />
   <E K="Contact_CreatorsTitle" V="Photographer" />
   <E K="Name" V="generic-copyright-preset" />
   <E K="Status_CopyrightNotice" V="© YYYY pName" />
   <E K="Status_JobIdentifier" V="SessionName" />
   <E K="Status_Title" V="JobName" />
   <E K="Status_UsageTerms" V="All rights reserved" />
</SL>


Will update...
LPb
 
Posts: 8
Joined: Mon Feb 09, 2015 9:31 pm
Location: Belgium

Re: workaround for setting next capture copyright metadata?

Postby LPb » Thu Mar 14, 2019 2:18 am

1.The generic preset file is in the resources folder.
2.The script copies preset file to the CO preset folder
3.The following code should replace some of the text in the new preset file. Only it's not working for me. It wasn't clear from the replies I got where the error was occurring, so I added some code for troubleshooting.

Code: Select all
set theMetaPreset to (path to resource "cr.copreset")
               
--test
tell application "Finder"
   reveal theMetaPreset ---OK!!
end tell
--
               
tell application "Finder"
   duplicate file theMetaPreset to folder ((path to home folder as string) & "⁩Library⁩:Application Support⁩:Capture One:Presets60:Metadata⁩:") with replacing
end tell
               
set newMetaPreset to ((path to home folder as string) & "⁩⁩Library⁩:Application Support⁩:Capture One:Presets60:Metadata⁩:cr.copreset")
               
--test
tell application "Finder"
   reveal newMetaPreset ---OK!!
end tell
--

set thePhotog to the text returned of (display dialog "photographer's name" default answer "")            
               
--replace pname--
set stringToFind to "pname"
set stringToReplace to thePhotog
               
set theContent to read newMetaPreset as «class utf8» --->ERROR<---
               
set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, stringToFind}
set ti to every text item of theContent
set AppleScript's text item delimiters to stringToReplace
set newContent to ti as string
set AppleScript's text item delimiters to oldTID
try
   set fd to open for access newMetaPreset with write permission
   set eof of fd to 0
   write newContent to fd as «class utf8»
   close access fd
on error
   close access newMetaPreset
end try
               
--replace yyyy--
--replace SessionName--
--replace JobName--
ERROR: Can’t make "Macintosh HD:Users:USR1:⁩⁩Library⁩:Application Support⁩:Capture One:Presets60:Metadata⁩:cr.copreset" into type file.

Am I missing something?
LPb
 
Posts: 8
Joined: Mon Feb 09, 2015 9:31 pm
Location: Belgium

Re: workaround for setting next capture copyright metadata?

Postby Eric Nepean » Thu Mar 14, 2019 4:35 am

There are several different formats used for describing files, and I don't have it all at my fingertips just now.
  • Alias--> uses the ":" as separator, starts with "Macintosh HD:"
    • An Alias is locked to the file object and represents it, if you move the file, the alias changes--> the file MUST exist
      A string representation of an Alias is not locked to the object
  • POSIX--> uses "/" as separator, starts with "/"
    • a POSIX reference represents a file object but is not locked to the object
  • Finder's definition of file has some subtle differences, can't find the details just now

Its not quite clear which line of your script is causing the error. But if you were to open Script Editor's Log History window, and select "Replies" it would show the last messages and replies before the error, and error itself. I find this very informative, if you could post that as "code" that would be informative and I might be able to help you better.

Here is a snippet of code from something I did last October that works, it might give you a useful example.
(I use "_ps" to designate a POSIX file reference which is a string, and "_as" to rperesent the string equivalent of an alias file reference)

Code: Select all
tell application "Capture One 12" to set theImageFilePath_ps to get path of parent image of primary variant

set theImageFile_as to get (get alias POSIX file theImageFilePath_ps) as string
tell application "Finder" to duplicate file theImageFile_as to folder backupFolder_as with replacing


Here is another possbly useful example from my logging handler "InitializeLoqqing5()"
Code: Select all
         -- create the document and the folder if necessary
         -- Do not use finder to test for the file existence because it has a bug that ignores leading 0's
         -- https://www.macscripter.net/viewtopic.php?id=45178
         set targetFolderParent_a to alias (get path to desktop folder as text)
         set targetFolderParent_p to get POSIX path of targetFolderParent_a
         set targetFolderName to "ScriptReports"
         set targetFolder_p to (targetFolderParent_p & targetFolderName)
         set ResultDocPath_p to targetFolder_p & "/" & DocName_Ext
         
         try
            set ResultDocPath_a to (get alias POSIX file ResultDocPath_p)
         on error
            try
               set targetFolder_a to (get alias POSIX file targetFolder_p) --x1
            on error
               tell application "Finder" to set newFolderRef to make new folder at targetFolderParent_a with properties {name:targetFolderName}
               set targetFolder_a to newFolderRef as alias
            end try
            tell application "Finder" to set newFileRef to make new file at targetFolder_a with properties {name:DocName_Ext}
            set ResultDocPath_a to newFileRef as alias
            set targetFileWasCreated to true
         end try
Eric Nepean
 
Posts: 608
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: workaround for setting next capture copyright metadata?

Postby hsautter » Thu Apr 18, 2019 1:07 am

Maybe I am missing something?

If you save a user preset with all the needed copyright information
then you can apply the style during the capture.

OK... so if I missed the point.... consider this:

if you setup a "hot folder" and then copy a file with the metadata into that folder
it will be "captured" and will show up in the "Recent Captures" collection.
Copy from last may then work as you wanted (but I did not try it)
hsautter
 
Posts: 11
Joined: Sat Jun 05, 2010 4:05 am

Re: workaround for setting next capture copyright metadata?

Postby SeanMurp » Tue Apr 30, 2019 8:57 pm

Hey LPb,
I just started looking into a solution for applying metadata pre-shooting today, as well. After reading your initial steps I think you're really close. Instead of trying to load this preset into the Metadata Next Capture Adjustment you can set it as the Styles because it sees these metadata presets the same as an image User Style.

So, as long as you know the name of the metadata preset file you've created then you can apply it to the Next Capture Adjustments with the following (**NOTE - exclude the file extension**):

Code: Select all
tell application "Capture One 11"
   set apply styles of next capture settings of current document to {("Name_Of_Preset_File")}
end tell



You can also use multiple metadata presets and/or User Style files by comma separating within the curly brackets. Example:
Code: Select all
set apply styles of next capture settings of current document to {("19-04-23 modelName AM1 B9 photogName W"), ("ASCCC1234567890"), ("onFig_storeName_white")}


I have confirmed that these apply in Capture One 11 but don't have a camera on-hand to confirm that the data is correctly applied on capture. We use this daily for User Styles and that works as expected. Just haven't testing with metadata.

LPb wrote:Sooo...

After all this and some testing, I can confirm that this method in general does not work.
CO does not recognise a previously imported file as a source for using Next Capture Adjustments with Metadata: 'Copy from Last'.
Could have easily tested this before hand of course :roll:

New approach:
I have saved a metadata preset, which I plan to copy to CO's metadata presets folder at the start of the session and have the script replace text pName, YYYY, JobName and SessionName with specified input.
This way the metadata will be only a few clicks away. Still better than typing it in manually I guess.
Code: Select all
<?xml version="1.0"?>
<SL Engine="1200">
   <E K="Contact_Creator" V="pName" />
   <E K="Contact_CreatorsTitle" V="Photographer" />
   <E K="Name" V="generic-copyright-preset" />
   <E K="Status_CopyrightNotice" V="© YYYY pName" />
   <E K="Status_JobIdentifier" V="SessionName" />
   <E K="Status_Title" V="JobName" />
   <E K="Status_UsageTerms" V="All rights reserved" />
</SL>


Will update...
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: workaround for setting next capture copyright metadata?

Postby SeanMurp » Tue Apr 30, 2019 9:52 pm

Just confirmed this to work as expected with next shots.

Code: Select all
tell application "Capture One 11"
   set apply styles of next capture settings of current document to {("Name_Of_Preset_File")}
end tell
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: workaround for setting next capture copyright metadata?

Postby SeanMurp » Wed May 01, 2019 10:05 pm

Finding one issue with using the metadata preset in the Styles of Next Capture Adjustments. It seems to clear the metadata preset from NCA upon quitting of Capture One. Seems that it needs to be manually or programmatically set each time Capture One is opened. User Styles do not seem to clear, though. Just the User Presets.

I'm only concerned about this with CO crashes or when a user restarts the app in hopes of clearing some other issue. Users forget to check these settings so we'll need to try re-setting with each new item that they photograph.

Both Capture One 11 and 12 act in this way.
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest