I hit a wall when trying to convert one of my old v2python scripts making use of curves. The problem is that the curves_spline(...) API function works in linear space, with no option to use curves in non-linear space. Designing curves in linear space is a nightmare, so don't even start me on this ;-)
Simply converting the curves coordinates to linear don't work, as x values are compressed to the left, and the result is very, very ugly. The right way to do it would be to sample many points along the curve, by applying the Catmull-Rom splines algorithm, but these splines require 4 points to work, and I have no idea how GIMP calculates the first and last segments.
It seems I'm not the only one on the internet with this problem since 3.0, and all questions of this kind are generally left unanswered, so I wanted to share a mildly clever little hack I found here.
The idea is to transform the coordinates values to linear, apply the non-linear spline curve, and transform back the values to the original non-linear space.If you find this back-and-forth confusing, so do I, but after much brain storming and many tests I can say that it works really well... except for 8 bits integer images which really don't like 3 consecutive operations in linear space!!! (please keep that in mind)!
Here is my code. Reuse it as you wish!
Code:
def srgb_curves_spline(drawable, channel, spline) :
# GIMP 3.0 API curves functions only work in linear space. This function is a hack
# to reproduce the effect of a non-linear srgb spline curve.
# IMPORTANT: this function does NOT work well with 8 bits integer images.
# The "spline" parameter is a list of x y coordinates of the spline points.
# See the GIMP API doc for the channel parameter...
# example: 'Gimp.HistogramChannel.VALUE' (without quotes)
# Non-smooth points are not supported.
# License is GPL3: http://www.gnu.org/licenses/gpl.html
samplecount = 1024 # count of equidistant samples in linear space
linofx_curve = []
srgbofx_curve = []
i = 0
while i < samplecount :
# current step in linear space
xlin = float(i) / (float(samplecount) - 1.0)
# srgb to linear
if xlin < 0.0031308 :
linofx_curve.append( xlin * 12.92 )
else :
linofx_curve.append( 1.055 * xlin**(1.0/2.4) - 0.055 )
# linear to srgb
if xlin < 0.04045 :
srgbofx_curve.append( xlin / 12.92 )
else :
srgbofx_curve.append( ( (xlin+0.055)/1.055 )**2.4 )
i += 1
# end while
# apply the curve surrounded by a back-and-forth to linear space values
# note that we don't change the color space of the image, it's just en intermediate
# representation of values
drawable.curves_explicit(channel, linofx_curve)
drawable.curves_spline(channel, spline)
drawable.curves_explicit(channel, srgbofx_curve)
return
Notes:
The default "srgb" color space is used for the non-linear space. If you really need curves in other spaces, change the transfer functions accordingly.
You can tweak the "samplecount" parameter for performance (down to 256). The value chosen (1024) ensures good quality conversion of dark values, but 256 is perfectly acceptable.
e-on software products have served the media and entertainment industry for over 27 years. Following its acquisition by Bentley Systems in 2015, e-on software’s technologies have been integrated into various Bentley products and have been used by valued customers and partners world-wide.
For over 39 years, Bentley’s focus has been to serve engineers and other professionals responsible for designing, constructing, and operating sustainable infrastructure. To keep our focus, we have decided to end sales for VUE, PlantFactory, and PlantCatalog. These products will not be further developed, and support will be limited to critical security patches.
However, we are offering free downloads and usage of VUE, PlantFactory, and PlantCatalog as perpetual versions to anyone interested in continuing to utilize these products and technologies! Simply download the product and acknowledge the new end-user-license-agreement (EULA) agreeing to using the software without support.
Hi!. Im currently working in a three monitor setup. Handy. The problem i have with Gimp is that for some reason it starts each time where he wants. I want it starts in the main monitor, at center of the three. It is the main monitor on windows setup. But Gimp sometimes starts at right monitor, sometimes at middle, sometimes at left... Funny! But bother a little, you need to drag it, maximize, etc, before start to work.
I have changed preference in "Windows management" but no change. It still opens where it desires.
Any tip?
Edit: I found what happens. Gimp follows my mouse. If i move my mouse to another monitor after click GIMP icon, gimp opens where my mouse is placed. So... you need to waaaait gimp totally open, to continue working...
Hi, I would like to know how to copy the content of colors channels RGB (Red, Green and Blue) into Green, then copy the content of Alpha channel into Red ?
I tried it on PS and it was quite easy, but I can't manage to reproduce it on Gimp.
I noticed this forum was down for awhile today. These errors are quite common and are mostly mysql database errors. From memory they usually mean stopping and re-starting the database but they need expert attention. Congratulations to the admins at Gimp-Forum
I used to use GIMP 2.10, and recently updated to GIMP 3.0.6 to use the non-destructive editing for text effects.
My work often involves creating many sub-projects, and then compositing them together into one larger project. Keeping the sub-projects intact allows me to alter elements after importing to adjust the overall composition.
Naturally, when opening a project as layers, any elements outside the sub-project's canvas are no longer clipped off, due to the main project having a larger canvas.
For this reason, I started making the root layer of each sub-project a layer group, and using a layer mask to make only the parts within each sub-project's canvas visible when imported into the main project.
Normally, this works phenomenally.
However, when I tried to use NDE text effects in a sub-project today, I found that the presence of effects causes layer masks to not be imported when opening a project as layers.
At the moment, I can just merge down the effects before saving the sub-projects, but I would greatly prefer to keep these effects intact and editable.
The layer group I import each sub-project into has a layer mask of the same size, so the layer mask in the sub-project is more for the ease of lining up their boundaries. I could simply add a layer to each sub-project that paints a bounding box in black outside the canvas, thus making the sub-project's layer mask unnecessary. But making such an edit to all my sub-projects when I've been using a template with the layer mask already applied for a long time now feels like alot of tedious work.
I wanted to ask around if this was a known issue, perhaps one that has already been addressed in a development build, or if this is due to some limitation of how effect filters, masks, and open as layers interact, as well as any other potential workarounds.
Here's one of the sub-projects
Here's the result when effects are active. Notice that the layer mask on "Pokemon LeafGreen.xcf" is missing
Here's the result when the effects are merged down before saving and opening as layers. Notice that the sub-project is clipped at the bottom where the original sub-project's canvas boundary ended
Any input, verification of this issue, anything, is greatly appreciated. Thanks!
Hi. Working on some photo retouching i found usefull to clone some details from other pictures, elements from background, textures, etc. Usually i navigate that stored photos trough some external program, like could be xnview. Would be interesting be able to "clone" from any portion of the screens you have, instead to open the file in Gimp.
just saying...