Creating Rules - marcapelini/RTProfileSelector GitHub Wiki

If you have correctly installed RTProfileSelector and configured RawTherapee, you can now proceed to creating your own rules.

Rules are defined in a file named RTProfileSelectorRules.ini. RTProfileSelectorRules.ini is a simple INI-style file where each section must be named for one of your custom profiles, and the entries are the Exif keys and respective values which you want to match the particular profile.

Besides simply matching the keys to the exact values from the Exif information, as of RTPS 1.0.2 you can also define more complex rules: you can negate a value, compare numeric ranges, and lists of values. See notes at the bottom of this page.

There can be as many sections in RTProfileSelectorRules.ini as you wish, and you can have more than one section with the same name, but with a different set of Exif fields (that is, different rules), if you want to apply the same profile for different combinations of Exif fields.

There can be as many fields in a single rule section as you wish. If there are different rules which match a particular image file, RTPS will pick up the most restrictive one, that is, the one with the largest number of fields.

Tip:

  • While creating your rules, you may want to take a look at the file RTProfileSelector.log (located in the same folder as the RTProfileSelector executable). The log file is updated every time RTPS is run, and there you will find information about which profile was selected, what .pp3 file was created and where, and any errors that may have occurred. Example:
RT key file: /home/mc/.cache/RawTherapee5-dev/CPB_temp_1.txt
Calling exiftool: exiftool -t -m -q "/media/mc/bkp_interno/Camera/2011/Ferias_2011-03-19_30/P1030431.RW2" > /home/mc/.cache/RawTherapee5-dev/P1030431.txt
Base profile file selected: /home/mc/.config/RawTherapee5-dev/profiles/Default.pp3

Creating a rule

The principle is simple:

  • You enable RTPS's "view Exif info" mode
  • Run RPTS (from within RawTherapee) on a photo for which you want to create a rule, that is, automatically assign a profile based on Exif information
  • Look for any Exif keys that might be useful for the rule you want to create
  • Create a rule in RPPS's rules file, associating a given custom profile to a set of Exif keys and values, so that any of your photos whose Exif matches the same criterion will be assigned the same processing profile

Let's go through all this one step at a time. To better follow this part of the tutorial, I suggest you use the sample photo (P1090268.RW2) which I have provided in the project's "samples" folder. Though nothing of artistic value, it was taken with my Panasonic GM1 set to monochrome, and that's the base for the rule we will be creating.


  • In RTPS's installation folder, open the file RTProfileSelector.ini with a text editor and enable the ViewExifKeys entry (be sure to save it before next step). Note: you only need this to have access to the Exif fields for the particular image you want to create the rule for, so you will probably want to disable it again once you're done with creating the rule.

  • Open the provided sample raw file with RawTherapee. If everything has gone as expected, a text editor window should open with the contents of a text file showing the Exif keys and values extracted from the photo:


  • Each camera model, even from the same maker, will mark differently photos taken in their monochrome/B&W modes. So for our rule we need to locate the "Camera Model Name" and some other key that might convey the information that the picture was taken in B&W. In the case of the GM1, this proved to be the "Photo Style" key. Since we want photos taken in B&W with this camera to be shown in black and white in RT, our simple rule includes both the GM1 "camera model" and the monochrome "photo style":

Note: There can be any number of rules pointing to the same processing profile. In my case, I also have B&W photos from two other cameras that I want to be given the same "Generic BW" profile, so my actual rules file looks something like this:

[Generic BW.pp3]
Camera Model Name=DMC-GM1
Photo Style=Monochrome

[Generic BW.pp3]
Camera Model Name=DMC-LX5
Film Mode=Dynamic (B&W)

[Generic BW.pp3]
Camera Model Name=DMC-GF1
Color Effect=Black & White

All three cameras are from the same maker (Panasonic), and mark their "black and white" modes quite differently, so I needed three different rules to use the same profile. That's why you will have to look at the Exif fields from you own camera and see which fields might correspond to a particular rule that you want to create.

Just to illustrate one more point about rules: RTPS will select the most restrictive match, that is, the matching rule with the greater number of fields. With this in mind, I was able to create one more rule for my GF1, which at one point I converted to infrared: I wanted the B&W photos taken with the GF1 before the conversion to use the "Generic BW" and the ones taken after the conversion to be assigned another profile (which I call "Infrared BW"). Since the camera still puts out the same Exif information as before, I had to use the fact that, after the conversion to infrared, I set a custom white balance in the camera, so here's the extra rule that I have for the GF1:

[Infrared BW.pp3]
Camera Model Name=DMC-GF1
Color Effect=Black & White
White Balance=Manual
Color Temp Kelvin=5300

Simple and yet flexible!


Of course, our rule will only work if we have a matching profile, but chances are you don't have one named "Generic BW", so in the steps above you must have seen the colour version of the sample photo. So, let's now go through the process of making the custom profile needed for the rule we've just created:

  • Open the provided raw file in RawTherapee and manually assign one of its bundled BW profiles:

  • Now click the "Save current profile" button and name it _exactly _"Generic BW.pp3" (for the purpose of this exercise):


Now that you have a "Generic BW" custom profile, we can check that our rule is working.

  • Clear the BW profile that we have manually assigned. Right-click on the image thumbnail and select "Processing profile operations|Clear":

  • The photo should be shown in colour once again:

  • Now you can force RTPS run on the image again, by right-clicking on the thumbnail and selecting "Processing profile operations|Reset to default":

Voilà! It should be B&W again.

If you really want to make sure your rule is working, you may close RawTherapee, delete the sidecar P1090268.RW2.pp3 file from the folder, run RT once again and see that the image opens in black and white.


Complex Rules

The basic rule format (KEY=VALUE) provides for comparison of the exact value declared to the corresponding value taken from an image file. When you declare several lines in a rule, they are evaluated one by one, and the rule is considered as a match if all entries (that is, an AND logical operation) are matched. To alow for sightly more flexible rules, as of release 1.0.2 RTPS also supports the following extensions:

  • Negating: If the value is preceded by an "!" (exclamation sign), the expression is TRUE if the Exif value is different from the one declared.

    • Matches any camera except the DMC-GM1:

      Camera Model Name=!DMC-GM1

    • Matches any white balance setting different from "Auto":

      White Balance=!Auto

  • Numeric range: If a particular field is convertible to a number (e.g.: "Focal Lengh", "ISO", "Aperture", "Exposure Time"), you can use the "~" (tilde) character to define a range of values to be matched. The lower value for the range must be on the left side of the "~", and the greater on the right side.

    • Matches any aperture value between (and including) 3.0 and 4.5:

      Aperture=3.0~4.5

    • Matches any focal length value between (and including) 22 mm and 40 mm:

      Focal Length=22 mm ~ 40 mm

    • Matches any exposure time between (and including) 1/1000s and 1/500 (remember 1/1000 is less than 1/500!):

      Exposure Time=1/1000 ~ 1/500

    • Matches any ISO value not between (notice the ! operator) 400 and 640:

      ISO=!400~640

    • Matches any aperture less than or equal to 3.0:

      Aperture= * ~ 3.0

    • Matches any focal length greater than or equal to 40 mm:

      Focal Length= 40 mm ~ *

  • Value list: Defines a list of possible values to be matched for a field. Each value must be separated by a "|" (pipe) character. The items themselves can be simple values or any combination the above negation or range operators.

    • Matches cameras DMC-GM1 or DMC-GX1 or DMC-GX7:

      Camera Model Name=DMC-GM1|DMC-GX1|DMC-GX7


Previous page: Integrating with RawTherapee

Next page: Partial-Profile-Rules