RawTherapee
RawTherapee copied to clipboard
Allow date as output template formatting string
I've recently switched from LR to RT and I am really impressed. However there are two things which I really miss in the batch queue.
-
Batch resize option If you are reducing the size of a big collection of pictures, resizing every single of them individually is quite tedious. It would be really nice to have the possibility to resize pictures in batch queue by defining width, height or Megapixel limit (while keeping the ratio) and also an option to avoid enlarging.
-
More formatting options for naming the exported files I use the date as a prefix to make the exported files sortable by the original date of the picture. There are surely other formatting options which other people miss.
- http://rawpedia.rawtherapee.com/Batch_Adjustments_-_Sync
- One request per issue please.
Sorry, as both were related to batch queue I've mentioned them both in one go.
Thanks for hinting to the sync feature, it's surely much better, however you still have to resize portrait and landscape pictures separately. Additionally you might want to do multiple exports of the same picture set, say one in hi-res and another one in low res. So if resize attributes were to belong to the export "session" instead of the picture itself, it would feel more intuitive IMHO.
I'd also like to have a few more options for exporting. :smile:
My workflow is to change something and watch the differences between exported images using an image viewer. This works much better for me than using snapshots because the rendered images have a higher resolution, the switch is faster (tap of a key, no re-calculation necessary) and there is less bias (I made a change, so it has to be better).
However, most image viewers (for example Geeqie on Linux) sort the first image last because it has no number:
-
image-1.png
-
image-2.png
-
image-3.png
-
image.png
And image deleting a few images to concentrate on bigger changes, say image-2.png
. RawTherapee would now render image-2.png
, followed by image-4.png
. Also, some image viewers sort image10.png
alphabetically, that means before image9.png
. Sorting images by creation time doesn't work well, either, because I often do a first round of editing and then finish up later.
So here are my ideas for additional "tags" during export:
-
%nx
(x
is the minimum number of digits) for adding a number:-
%n1
(1
and10
) -
%n2
(01
and10
) - if the number was higher than the highest one in existing files of the same base name (instead of the first missing one), you'd even solve the "deletion problem"...
-
- tags for time of export, compatible with
strftime
for sorting by day and/or time-
%d
(day of the month as a decimal number, range 01 to 31) -
%m
(month as a decimal number, range 01 to 12) -
%Y
(year as a decimal number including the century, 1987) -
%H
(hour as a decimal number using a 24-hour clock, range 00 to 23) -
%M
(minute as a decimal number, range 00 to 59) -
%S
(second as a decimal number, range 00 to 60) -
%F
(equivalent to%Y-%m-%d
, the ISO 8601 date format) -
%T
(time in 24-hour notation,%H:%M:%S
) -> filesystems won't like this much, I'd use hyphens instead of colons
-
Thanks!
Martin
I'd be interested in implementing this one, building on my implementation of #6915. It would keep me busy for a while, working on it just a few hours now and then, but since it's been hanging around for years, I suspect nobody will complain too loudly about a bit more delay.
#6915 expanded the template options somewhat, so that the supported percent specifiers are now d, f, p, P, r and s. For date and time we could use %t"time format string"
(quotes prevent strftime specifiers being treated as queue-template specifiers), but really you'd want the ability to select which date/time value to use:
- date/time of export
- date/time that the file was last saved
- date/time when the photo was taken
- maybe some others that I've missed
@Lawrence37, what do you think of %t[type]"[format]"
, where:
-
[type]
= optional "which one" specifier:- E (the default, if
[type]
is omitted) = when the export operation started - F = when raw image file was last saved
- P = from EXIF data, when the photo was taken (falling back to
Exif.Photo.DateTimeDigitized
, or maybe D for that)
- E (the default, if
-
[format]
= format string compatible withstd::formatter<std::chrono::sys_time>
With the proposal for %nx
I suppose it isn't impossible that someone is using a template with %n
followed immediately by a digit, in which case the change would break their template. A way around that is to leave %n
as-is, and add %Nx
where x is the minimum number of digits.
I mentioned in GH-6920 that the tooltip for the template field is getting huge, and that you'd really like to leave that information on the screen while you're crafting your template. Reproduced below, because that change could perhaps be included here. The idea is that a new panel would appear on demand, presenting full help, and the tooltip would be simplified.
It seems to me a better approach would be to put a help button beside the field, perhaps like this:
The "?" icon shown would be a toggle button, which when in the on state causes help text to appear in a panel perhaps inserted between the control panel and the file thumbnail panel. That means you would be able to keep the help on the screen while you're editing the template. I don't propose including that change here, but it might be appropriate as a separate task.
I have a few concerns.
- Ease of use. Is it hard for the average user to come up with the correct template? As programmers, we are used to dealing with formatters. What about non-programmers? I can't speak on their behalf, but hopefully it's easy enough to understand
%tE
means export time and it is followed by a time format surrounded by quotes. -
std::formatter<std::chrono::sys_time>
is C++20 but RawTherapee is on C++11. There isstd::put_time
, but that also has... - Mandatory padding. Suppose someone wants to format January 23, 2024 as
2024-1-23
. The closest they can get is2024-01-23
(%Y-%m-%d
). There are a few other date-time elements that also must be padded.
@Lawrence37 for point 2, the answer is presumably strftime.
I think points 1 and 3 conflict, in that providing a padding option would increase complexity for non-programmer users. For point 3 I strongly suspect the number of users who will explicitly require values that can't be sorted alphabetically will be rare.
So I think the key point is your first one. I guess a reasonable question is whether the average user will edit templates at all, as opposed to either:
- selecting an output directory directly, or
- running RawTherapee exclusively from within other programs, so that the queue feature isn't involved at all
The users of the template feature are those who require special naming of output files and/or directories. I think the right question is not whether the solution is simple, but rather whether it's simpler than the alternative. The only ways I can think of to make it simpler than what I've proposed is to make it more restrictive, such as only letting users select from a small number of "canned" time/date formats.
An easy way to avoid overwhelming some users while assisting others is to state in the help that a feature is "advanced", providing information on where to get more details. We could show a few examples and also say that for complete template help you can refer to the strftime documentation.
@Lawrence37 I guess we could have a "basic" tag with an "advanced" variant, something like:
-
%t[type][digit]
selects one of 10 predefined format options. For example maybe%tP0
is like20240123
,%tP1
is like2024-01-23
and so-on, including some with both the date and the time. Since you have (once #6920 is merged) a preview field, you can just try all the digits until you see one you like. -
%t[type]"[format]"
is the "advanced" format, usingstrftime
to process the user's format string. - The pop-up help would document what the digits mean and just say something general about the advanced format, perhaps along the lines of "it's documented on the wiki".
If we wanted to omit [type]
I think most people would expect to see the date on which the photo was taken ('P' in my earlier comment). I suspect what I called the 'F' type (date of last file save) would be rarely required, but people might want to use the export date (my 'E' type) especially in directory names. One option there would be slightly cryptic, but in keeping with the %p
/%P
specifiers in #6915 -- %t
for shooting date, %T
for export date.
Point 1 is more about the syntax and could possibly be remedied by carefully-worded documentation. For example, it sounds more complex when it's described as a three-part template variable starting with %t followed by the type of time followed by the time format. Compare that to a two-part template variable, starting with the type (%tP, %tE, %tF, etc.) followed by the time format.
For the padding, I've seen non-padded numbers used in other contexts because it's more "natural"... or is that just a US thing like the m/d/yy shenanigans?
Looking at https://en.cppreference.com/w/cpp/chrono/c/strftime I see %e
, as of C++11, "writes day of the month as a decimal number (range [1,31]). Single digit is preceded by a space." -- why did they put that space there? Weird.
Help-wise, maybe we show each of the three options with some specific quoted strings, then say how to get the complete list.
Date and time specifiers:
-
%tE"%Y-%m-%d_%H:%M:%s"
= when export started (example "1999-12-31_23:59:59") -
%tF"%Y-%m-%d"
= when file was last saved (example "1999-12-31") -
%tP"%Y/%B/"
= when photo was taken, from EXIF (example "1999/December/")
The quoted string defines the format of the resulting date and/or time. The format strings above are just examples. The string can use all conversion specifiers defined for the std::strftime function.
(That last part could instead say that all available specifiers are documented on the wiki, or provide a link to cppreference. We could also show some example quoted strings.)
Examples are nice. It's disappointing there's no no-padding options without using 3rd party libraries. That made me realize the GNOME libraries may have something. GLib has g_date_time_format.
The format strings understood by this function are a subset of the strftime() format language as specified by C99. The D, U and W conversions are not supported, nor is the E modifier. The GNU extensions %k, %l, %s and P are supported, however, as are the 0, _ and - modifiers. The Python extension %f is also supported.
So no "American date" (%D
), week of the year (%U
and %W
), or the locale alternative modifier (E
), but it does support padding modifiers. The downside is the documentation is not as pretty.
@Lawrence37 It seems like I have everything I need to get started on this task, using the Glib formatting function. If you agree, please assign it to me. Also, can #6920 be merged, so I can build on that with this work?
@sgilbertson I've assigned this issue to you and merged your pull request.
I created a draft pull request. The help pane, toggled on and off with a "?" button, is working (but not the actual template functionality, yet). Below is an excerpt from the on-screen help, for the "Date and time" section. I welcome in particular suggestions on some other example format strings to include.
The help is generated with a mix of code and language-specific strings. The example format strings are in the C++ code, and the results printed for each one are calculated (from the current time) rather than coming from the default strings file. It is easy to add more examples (just add to the initializer for dateTimeFormatExamples
).
Three different date/time values may be used in templates:
%tE"%Y-%m-%d" = when export started
%tF"%Y-%m-%d" = when file was last saved
%tP"%Y-%m-%d" = when photo was taken
The quoted string defines the format of the resulting date and/or time. The format
string %tF"%Y-%m-%d" is just one example. The string can use all conversion
specifiers defined for the g_date_time_format function (see
https://docs.gtk.org/glib/method.DateTime.format.html).
Example format strings:
%tE"%Y-%m-%d" = 2024-02-11
%tE"%Y%m%d_%H%M%S" = 20240211_152732
%tE"%y/%b/%-d/" = 24/Feb/11/
I think those example format strings are enough because they show all the variables I expect will be most commonly used. If the current time is used to generate the examples, sometimes the last format string will not show what the -
in %-d
does though.
I changed the time for those examples to 2001-02-03T04:05:06.123456
local time, the result being (in particular 01/Feb/3/
):
Example format strings:
%tE"%Y-%m-%d" = 2001-02-03
%tE"%Y%m%d_%H%M%S" = 20010203_040506
%tE"%y/%b/%-d/" = 01/Feb/3/
Ready for review: #6951
Nice! I will have a look.
@Lawrence37 I believe I have addressed your concerns in #6951