Author Topic: setting color class based on variables?  (Read 4125 times)

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
setting color class based on variables?
« on: January 18, 2015, 03:21:50 PM »
Is it possible to set color class based on variables?
For example, can I make it so all RAW files get tagged with red?

Something like,

If ({quality} == 'RAW') colorClass = 1;

That sort of thing.

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 21946
    • View Profile
    • Camera Bits, Inc.
Re: setting color class based on variables?
« Reply #1 on: January 18, 2015, 03:37:36 PM »
Is it possible to set color class based on variables?
For example, can I make it so all RAW files get tagged with red?

Something like,

If ({quality} == 'RAW') colorClass = 1;

That sort of thing.

Yes.  While not with a logical expression as you have described, one can use variables and Code Replacement along with the IPTC Stationery Pad to set the Color Class, Rating, or Tag of a photo.

You would have to make a Code Replacement file that has a mapping from the variable output to the desired color class index.  Then in the IPTC Stationery Pad you would use the Color Class field and change the popup menu to "Evaluate:" and then in the new text field that appears, you would enter your Code Replacement delimiter (by default it is the backslash '\') then the {variable} followed by another Code Replacement delimiter.

Then when you apply the IPTC Stationery Pad, the variable will be extracted, looked up in the list of codes and if a replacement is found, the replacement will be turned into a number (replacements that are not numbers will evaluate as zero or Color Class none) and then that number will become the Color Class.

HTH,

-Kirk

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #2 on: January 18, 2015, 04:59:20 PM »
Thanks Kirk.

I just tried that but so far can't get it to work.

In my codes.txt file I have "RAW  6" as the only line.

When I type \RAW\ it immediately turns into a 6 and when I apply the stationary IPTC the color turns blue as expected, but when I set color class evaluate \{quality}\ it does not effect the color.  What could I be doing wrong?


Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2523
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: setting color class based on variables?
« Reply #3 on: January 18, 2015, 11:24:16 PM »
If you put \{quality}\ in e.g. the caption field in the IPTC stationary, what does it expand to when you apply that stationary?
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 21946
    • View Profile
    • Camera Bits, Inc.
Re: setting color class based on variables?
« Reply #4 on: January 19, 2015, 09:10:41 AM »
I just tried that but so far can't get it to work.

In my codes.txt file I have "RAW  6" as the only line.

When I type \RAW\ it immediately turns into a 6 and when I apply the stationary IPTC the color turns blue as expected, but when I set color class evaluate \{quality}\ it does not effect the color.  What could I be doing wrong?

I tried this with some of my own images and it works fine.  Put {quality} as one of your thumbnail labels, and put \{quality}\ as one of your other thumbnail labels.  Then browse your contact sheet and see what kind of values you're getting.

-Kirk

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #5 on: January 19, 2015, 11:14:23 AM »
Hayo,

I haven't tried the caption field, but I did a test in the fields that get displayed under each thumbnail in the contact sheets and it appears the variable substitution works properly there. Here's what I see.

{quality} gets displayed as RAW
\{quality}\ gets displayed as 6

This appears correct since my code replacement file has the line
RAW  6

Neither {quality} or \{quality}\ seem to have any effect on the colorclass when put in the evaluate box for that option. However, if I put \RAW\ in that box is immediately turns the color under the thumbnail blue (blue is 6).

I wonder if it is a mac specific issue?


Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #6 on: January 19, 2015, 11:17:57 AM »
I just tried that but so far can't get it to work.

In my codes.txt file I have "RAW  6" as the only line.

When I type \RAW\ it immediately turns into a 6 and when I apply the stationary IPTC the color turns blue as expected, but when I set color class evaluate \{quality}\ it does not effect the color.  What could I be doing wrong?

I tried this with some of my own images and it works fine.  Put {quality} as one of your thumbnail labels, and put \{quality}\ as one of your other thumbnail labels.  Then browse your contact sheet and see what kind of values you're getting.

-Kirk

Kirk,
I did exactly this. The string {quality} \{quality}\ gets displayed correctly as RAW 6

So that part is working.

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 21946
    • View Profile
    • Camera Bits, Inc.
Re: setting color class based on variables?
« Reply #7 on: January 19, 2015, 01:35:07 PM »
What happens if you change your 'replacement' to the matching label name (for instance 'Red'), does it work better then?

What build of PM 5 are you running?

-Kirk

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #8 on: January 19, 2015, 01:51:34 PM »
I'll try that tonight and report back Kirk. I was under the impression the colorclass had to be an integer 0-8. I'll try both 'Red' and Red in the replacement file.

Not sure the version number but when I perform a check for updates it says I am running the latest version.

I am running on a macbook pro with OSX Mavericks.

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 21946
    • View Profile
    • Camera Bits, Inc.
Re: setting color class based on variables?
« Reply #9 on: January 19, 2015, 02:53:30 PM »
I'll try that tonight and report back Kirk. I was under the impression the colorclass had to be an integer 0-8. I'll try both 'Red' and Red in the replacement file.

Not sure the version number but when I perform a check for updates it says I am running the latest version.

I am running on a macbook pro with OSX Mavericks.

You can find the build number in the About Photo Mechanic dialog (on the Photo Mechanic menu).

Don't bother with 'Red', just use Red without the quotes.  Basically you want to match the same names as are used in your Color Class labels (in the General section of the Photo Mechanic preferences dialog.)

-Kirk

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #10 on: January 20, 2015, 06:27:26 AM »
I'll try that tonight and report back Kirk. I was under the impression the colorclass had to be an integer 0-8. I'll try both 'Red' and Red in the replacement file.

Not sure the version number but when I perform a check for updates it says I am running the latest version.

I am running on a macbook pro with OSX Mavericks.

You can find the build number in the About Photo Mechanic dialog (on the Photo Mechanic menu).

Don't bother with 'Red', just use Red without the quotes.  Basically you want to match the same names as are used in your Color Class labels (in the General section of the Photo Mechanic preferences dialog.)

-Kirk

Kirk,

It doesn't seem to work. I put the line

RAW  Red

in my code replacement file and there is still no color applied to the thumbnails when I apply the IPTC stationary pad to photos.

As a test, I put the phrase {quality} \{quality}\ in the contact sheet labels section and it properly expands to RAW Red under the thumbnails.

I also tried putting \{quality}\ in the Captions section of the IPTC stationary pad and when I click on the i button of a photo it was applied to I see the word Red in the caption.

So It appears the variable replacement is working properly in both these cases, which suggests that the evaluate feature for colorclass in the IPTC might be broken.  Can you try the same test on your end?

I am running Version 5.0, Build 15800

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 21946
    • View Profile
    • Camera Bits, Inc.
Re: setting color class based on variables?
« Reply #11 on: January 20, 2015, 06:42:46 AM »
I have done what I described to you earlier with success.  But I am using a newer development build than you're using.  If you'd like to try it for yourself, download it here:

http://www.camerabits.com/download/PhotoMechanic5R16242.dmg

-Kirk

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #12 on: January 20, 2015, 07:27:00 AM »
The feature seems to be working in that build.

Now all my RAW thumbs are being colored red, but the jpegs are left uncolored. Perhaps {quality} is not the right variable to key on?

For the jpeg images I see that \{quality}\ expands to just \\ in the info lines, so it appears quality is empty for these jpegs. I just extracted them from the RAWS in the same folder. Perhaps the extract operation does not populate quality?

If I wished to have all RAWs colored red and all jpegs colored blue, is there a better variable to use than {quality}? Maybe I should look at the filename extension? How would you do it?

Anyway, thanks for the beta fix. It is nice to see this feature implemented now. I can think of lots of uses for it in the future.

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 21946
    • View Profile
    • Camera Bits, Inc.
Re: setting color class based on variables?
« Reply #13 on: January 20, 2015, 07:42:47 AM »
I'd try {type}.  Use it in your thumbnail labels to see the range of values for your images.  Then update your Code Replacement file and use \{type}\ in the IPTC Stationery Pad in your Color Class Evaluate field.

-Kirk

Offline rjp

  • Member
  • **
  • Posts: 93
    • View Profile
Re: setting color class based on variables?
« Reply #14 on: January 21, 2015, 07:14:51 AM »
{type} works great Kirk!

I assume this feature will be included in your next official release. Is there any reason why I should not continue to use the beta you provided for now?

It is so great to see this ability to set color class based on variables working! I remember asking for it years ago and it didn't seem to generate much interest at the time.

The evaluate option is a very good idea. I wonder, can we include anything more complex in this field, relational operators for example?

For example, suppose I want to set the color class of all ingested photos to Red if their ISO >= 3200.

Is there a way to "evaluate" {iso} >= 3200 and if True then assign Red?