New: Extensions > Color > HSL Adjust

Bug #979208 reported by su_v
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
su_v

Bug Description

New module for 'Extensions > Color': HSL Adjust…
Allows to modify selection (or drawing) by adjusting Hue (360°, wraps around), Saturation (%) and Lightness (%)

Related:
Bug #171181 "group colour/color changes, brightness, contrast, HSV, more"
(comment #9)

Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
jazzynico (jazzynico) wrote :

Hey, I was about to post almost the same extension!
That's the confirmation we really need it.

Mine is a bit different, since it also includes features from the randomize extension.
Let's try to merge the best of our proposals!

Changed in inkscape:
status: New → In Progress
Revision history for this message
su_v (suv-lp) wrote :

> since it also includes features from the randomize extension

Potential drawback: 'randomize' can't be used (via verb) from the command line anymore if the two extensions are merged into one (without adjusting the last used settings via GUI before using command line call).

Revision history for this message
jazzynico (jazzynico) wrote :

Ok, let's add yours!

Changed in inkscape:
assignee: nobody → ~suv (suv-lp)
milestone: none → 0.49
Revision history for this message
jazzynico (jazzynico) wrote :

Slightly modified INX file (UI consistency and XML code formating).

Revision history for this message
su_v (suv-lp) wrote :

I was just recently thinking about your proposed version…
- Would you retract or keep the separate 'Randomize…' extension if you combine it to 'HSL edit/Adjust'? I hadn't really considered whether combined adjustments e.g. modulating the hue while randomizing saturation / lightness slightly are much more frequently used adjustments, than simply adjusting the hue by itself, or along with saturation? I'm not against using your combined one - just that I'm a bit more conservative wrt removing existing extensions (and their verbs, usable in old scripting or via dbus API).
- Redundant ranges in 'Hue rotate': I was never quite sure whether to use 180° or 360° for hue rotate, and had settled with the scheme used in the raster extension (HSB Adjust) [1], also because it allows to mentally spin/rotate the color wheel in either direction without doing any additionally math.
For saturation and lightness, I chose -100/+100 - unlike in the raster extension (not sure if I'm miserably failing in math, or -200/+200 is indeed the equivalent to the redundant range for hue rotate (assuming the normal range for saturation and lightness/brightness is '0 - 100%', also in ImageMagick++)).

[1] <http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/src/extension/internal/bitmap/modulate.cpp#L36>

Revision history for this message
su_v (suv-lp) wrote :

> Slightly modified INX file (UI consistency and XML code formating).

Modelines are not allowed in INX files? (yes, I know, inkscape only uses them for C/C++ code currently… - could be handy for scripts and XML files too IMHO, it makes formatting and keeping a consistent indenting when editing later on in vim so much easier ;) )

Revision history for this message
su_v (suv-lp) wrote :

Cont.:
> Slightly modified INX file (UI consistency and XML code formating).

Proposing to use 'type="int"' for all three sliders, like in 'HSL edit' (color_HSL.{inx,py}).

Revision history for this message
jazzynico (jazzynico) wrote :

> Modelines are not allowed in INX files?

I have no problem with modelines, but none of the existing INX files use it. Additionally, the indentation should be of 2 spaces for XML files. Lot's of INX files still use 4 spaces or even a tab, but I try to fix it each time I need to modify a file. Maybe I should fix everything so that it's cleaner...

> Would you retract or keep the separate 'Randomize…' extension if you combine it to 'HSL edit/Adjust'?

Yes, we can keep the old Randomize extension and add randomization in our new one too.
Ok, then I'm going to merge both extensions starting from my INX file and your Python file (your logic looks more clever than mine ;).

Revision history for this message
jazzynico (jazzynico) wrote :

New version, with random options.

Revision history for this message
jazzynico (jazzynico) wrote :

Extension added in the trunk, revision 11665.

Changed in inkscape:
status: In Progress → Fix Committed
Revision history for this message
Kryo Stat (xk1) wrote :

It seems to me this is related to this Wishlist Item:

https://bugs.launchpad.net/inkscape/+bug/171589

"Inkscape needs color tools (Hugh-Saturation, Brightness-Contrast, Curves, Levels, etc.) that adjusts everything at once in whatever objects are selected."

You are mentioning

Hue (360°, wraps around),
Saturation (%)
Lightness (%)

Do you think it would be possible to include Brightness-Contrast and Color Levels/Curves in this module since this all deals with color adjustments ?

Maybe later expand it even more to include colorize and other possible color adjustment operations ? That would eliminate the need to use Gimp for color correcting an exported image.

Thank you from a happy Inkscape user :)

Revision history for this message
su_v (suv-lp) wrote :

Kryo Stat wrote:
> Do you think it would be possible to include Brightness-Contrast and Color
> Levels/Curves in this module since this all deals with color adjustments ?

If you know how to code this in python, based on the RGB values used in the style properties of the selected vector objects, (or know links to code snippets or sample python-based implementations), I could imagine that some additional basic types of (not color-managed) adjustments could be added. Better though would be an internal implementation as mentioned in bug #171589 - the extensions are essentially just placeholders (IMHO):
- Extensions are external (python) scripts, and run in a separately spawned process which doesn't have access to internal functions of Inkscape.
- In the context of Inkscape's current extension system, these scripts cannot use fancy widgets for interactive GUI color adjustments.

For now, I'm attaching a variant of the 'HSL Adjust' extension which uses Python's 'colorsys' module [1] for all color conversions, and allows adjustments in either HLS or HSV color notation [2] (conversions are based on the RGB values as stored in the SVG source). The options to randomize the values have been dropped (for now). Note that I didn't run extensive tests, and that 'HSV' was added simply because it's readily available in a default python module (I'm not an expert wrt to color operations myself).
Maybe HSV is closer to what you had been looking for (at least wrt to Lightness/Brightness)?

> Maybe later expand it even more to include colorize and other possible color
> adjustment operations ?

You did explore the rest of the currently available color extension modules?
<http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Extensions-Color.html>

---
[1] <http://docs.python.org/2/library/colorsys.html>
[2] <http://en.wikipedia.org/wiki/HSL_and_HSV>

Revision history for this message
su_v (suv-lp) wrote :

> Kryo Stat wrote:
>> Do you think it would be possible to include Brightness-Contrast and Color
>> Levels/Curves in this module since this all deals with color adjustments ?

Attaching another extended variant of the extension (experimental!), with additional tabs 'Brightness' and 'Contrast':
- adjustable 'Brightness' is based on the 'Brighter/Darker' modules of the Color extensions
- adjustable 'Contrast' (experimental) is based on a rather randomly picked resource from the web, which produced plausible results with simple test cases:
  <http://www.dfstudios.co.uk/articles/image-processing-algorithms-part-5/>

Revision history for this message
su_v (suv-lp) wrote :

Latest version of (experimental) 'color-adjust-misc' extension is at
<http://bazaar.launchpad.net/~suv-lp/+junk/inkscape-extensions/files/head:/color-adjust-misc/>
(only minor changes compared to color_adjust_misc-v2.zip )

Revision history for this message
jazzynico (jazzynico) wrote :

Interesting improvements!
Just a bug (with files from revision 46) when setting brightness to 100%, the extension returns a ZeroDivisionError:
----
Traceback (most recent call last):
  File "color_adjust_misc.py", line 241, in <module>
    c.affect()
  File "D:\Inkscape\inkscape-12010\inkscape\share\extensions\inkex.py", line 267, in affect
    self.effect()
  File "D:\Inkscape\inkscape-12010\inkscape\share\extensions\coloreffect.py", line 39, in effect
    self.getAttribs(node)
  File "D:\Inkscape\inkscape-12010\inkscape\share\extensions\coloreffect.py", line 42, in getAttribs
    self.changeStyle(node)
  File "D:\Inkscape\inkscape-12010\inkscape\share\extensions\coloreffect.py", line 80, in changeStyle
    new_val = self.process_prop(val)
  File "D:\Inkscape\inkscape-12010\inkscape\share\extensions\coloreffect.py", line 90, in process_prop
    col='#'+self.colmod(c[0],c[1],c[2])
  File "color_adjust_misc.py", line 200, in colmod
    r_new,g_new,b_new=[min(int(round((c/FACTOR))),255) for c in [r,g,b]]
ZeroDivisionError: float division

Revision history for this message
su_v (suv-lp) wrote :

JazzyNico wrote on 2013-01-08:
> Just a bug (with files from revision 46) when setting brightness to 100%,
> the extension returns a ZeroDivisionError:

Thanks a lot for testing and providing feedback! Recent changes (r50):
- 100% brightness now handled without error
- formula for more brightness has been simplified (among other things because I failed to fully grasp the purpose of the i-based lower threshold in the original extension)
- black (0,0,0) now really stays unchanged
- the 'Brightness' and 'Contrast' options have been unified in a single tab

Revision history for this message
jazzynico (jazzynico) wrote :

Just tested r54. Everything looks perfect now!

Do you plan to add improvements? Now that the trunk is open to new code again, your changes would be welcome for 0.49.

Revision history for this message
su_v (suv-lp) wrote :

Additional 'Color > Adjust' modules for trunk are blocked by bug #1106031 (at least IMvHO). I will file a separate RFE report with additional modules for adjusting color components (currently still work-in-progress at <lp:~suv-lp/+junk/inkscape-extensions>) once that bug has been fixed.

su_v (suv-lp)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.