Two other useful bits of information: - This is version 2.0.7 running on Ubuntu 16.04. - If I perform a compress history stack prior to saving the style, everything works as expected (only one crop and rotate operation applied at correct sequence) via GUI and lua
Thanks James On Mon, Nov 7, 2016 at 11:33 AM, James B <[email protected]> wrote: > Hi all. First thanks for all the hard work on making darktable ... really > enjoying it. > > In taking my first stab at lua API programming, I've noticed an apparent > bug with the style handing. Under certain circumstances, styles created via > the GUI differ from style created from the same image via the lua API. The > problems occur when multiple history items of the same type (in my testing, > crop and rotate) occur back to back. The GUI will collapse these into a > single operation and save. Using this style on a duplicate of the original, > results in an image equivalent to the modified original, as expected. > > Performing the same operation via lua results in the crop and rotate > operations being split up, with some prepended before all other operations. > Applying this style to a duplicate, causes repeated crop and rotate > operations to be applied on top of each other causing a dramatically > different result image. > > Here is a database dump of the history of the original image > $ sqlite3 .config/darktable/library.db "SELECT * from history where > imgid=4146" > 4146|0|1|sharpen||1||7|0| > 4146|1|2|flip|����|1||7|0| > 4146|2|2|basecurve||1||7|0| > 4146|3|5|clipping||1||7|0| > 4146|4|5|clipping||1||7|0| > 4146|5|5|clipping||1||7|0| > > (Notice the three clipping operations in succession) > > Here is the DB dump of the style created via the GUI: > > $ sqlite3 .config/darktable/library.db "SELECT * from style_items where > styleid=3" > 3|0|1|sharpen||1||7|0| > 3|1|2|flip|����|1||7|0| > 3|2|2|basecurve||1||7|0| > 3|5|5|clipping||1||7|0| > > And here is the dump of the style created via lua: > > $ sqlite3 .config/darktable/library.db "SELECT * from style_items where > styleid=6" > 6|0|5|clipping||1||7|2| > 6|1|5|clipping||1||7|1| > 6|2|1|sharpen||1||7|0| > 6|3|2|flip|����|1||7|0| > 6|4|2|basecurve||1||7|0| > 6|5|5|clipping||1||7|0| > > (Notice clipping operations 0 & 1 prior to sharpen and others) > > Looking into the code, the chief codepath difference I see is that the GUI > uses a filter to dt_styles_create_from_image() while lua does not. This > filter can be seen in the sql debug output from the GUI style operation: > > [sql] /build/darktable-p3fEYL/darktable-2.0.7/src/common/styles.c:431, > function dt_styles_create_from_image(): prepare "insert into style_items > (styleid,num,module,operation,op_params,enabled,blendop_ > params,blendop_version,multi_priority,multi_name) select ?1, > num,module,operation,op_params,enabled,blendop_params, > blendop_version,multi_priority,multi_name from history where imgid=?2 and > num in (5,2,1,0)" > > Notice the "in (5,2,1,0)" in the SQL statement. The lua code appears to > hardcode NULL as the filter in the call to this function so no filtering is > applied. > > > Reproduction > - select image and enter darkroom > - choose crop and rotate and perform some crop action > - click on another tool (but don't do anything) > - choose crop and rotate and perform another crop action > - click on another tool (but don't do anything) > - at this point the history should have two consecutive but different > crop and rotate operations in the history stack > - return to light table, select image and create style from image > > - in lua: duplicate image, create style from original image > > Example lua code: > > local dt = require "darktable" > > dt.register_event("shortcut",function(event,shortcut) > local images = dt.gui.action_images > for _,v in pairs(images) do > style = dt.styles.create(v, "temp-"..v.filename, "temp") > end > end,"Create a duplicate of image") > > ___________________________________________________________________________ darktable developer mailing list to unsubscribe send a mail to [email protected]
