GIMP Chat http://gimpchat.com/ |
|
use of a color curves preset in a python filter http://gimpchat.com/viewtopic.php?f=8&t=20729 |
Page 2 of 3 |
Author: | dinasset [ Sat Jan 27, 2024 12:27 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
teapot wrote: I'm on an old version of 2.10 and my GimpCurvesConfig.settings has lines: (linear no) which Ofnuts script is also expecting. However Tim has taken it out as the, presumably later version, file on post #13 doesn't have them. ... I think that the "linear no" is added after having been used interactively, I see it now in my config file I attach the zipped file after having used it online (the first now is "the klast used") Attachment:
|
Author: | dinasset [ Sat Jan 27, 2024 12:50 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
@tin tried to put the explicit indication of where the file is in my samj's version, id est: Code: Select all settings=load("C:\\Users\\diego\\Desktop\\Gimp-2.10.36_Portable_32-64bit-Win\\Preferences\\filters\\GimpCurvesConfig.settings") but I still do get the error |
Author: | teapot [ Sat Jan 27, 2024 1:14 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
dinasset wrote: teapot wrote: I'm on an old version of 2.10 and my GimpCurvesConfig.settings has lines: (linear no) which Ofnuts script is also expecting. However Tim has taken it out as the, presumably later version, file on post #13 doesn't have them. ... I think that the "linear no" is added after having been used interactively, I see it now in my config file I attach the zipped file after having used it online (the first now is "the klast used") Attachment: GimpCurvesConfig.7z I think that means you need to change Tim's: Code: Select all # nameLine,timeLine,linearLine=islice(settingsFile,3) back to Ofnuts original: Code: Select all nameLine,timeLine,linearLine=islice(settingsFile,3) |
Author: | dinasset [ Sat Jan 27, 2024 2:55 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
Done as you suggested, teapot. Now my version displays all the messages sent by the filter, as the original tin's version. But the layer is not modified, as per tin. at least it seems so. |
Author: | dinasset [ Sat Jan 27, 2024 3:12 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
update: added stmts for green and blue to my version: EUREKA, curves applied. |
Author: | ofnuts [ Sat Jan 27, 2024 5:22 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
dinasset wrote: Sorry Tin and Ofnuts. - if I copy what you posted (included ofnuts' suggested change) I get a list of messages, but nothing else - whatever I add in the code, for instance create a new layer, it is executed but then no more filter messages but an error Attachment: error-msg.PNG As long as my little brain does not see at least one curve applied to an existing image I can't try to use the proposed flow. You too Tin says: does not work on existing image, which is what I need: apply a curve to the input layer. Thanks a lot for trying. "List index out of range" when you are using an index of 0 means that the list is empty. And if you have an empty list it is probably because you have no explicitly named settings (as uploaded my code filters out the auto-saved settings). |
Author: | dinasset [ Sat Jan 27, 2024 5:31 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
ofnuts wrote: dinasset wrote: Sorry Tin and Ofnuts. - if I copy what you posted (included ofnuts' suggested change) I get a list of messages, but nothing else - whatever I add in the code, for instance create a new layer, it is executed but then no more filter messages but an error Attachment: error-msg.PNG As long as my little brain does not see at least one curve applied to an existing image I can't try to use the proposed flow. You too Tin says: does not work on existing image, which is what I need: apply a curve to the input layer. Thanks a lot for trying. "List index out of range" when you are using an index of 0 means that the list is empty. And if you have an empty list it is probably because you have no explicitly named settings (as uploaded my code filters out the auto-saved settings). if you read my last post, solved, and added also the loading of green and blue data (tin did it only for red) and I got the layer updated! Now I have to find where and how to set the screening of a specific Preset (currently tin+mine load the first one). |
Author: | trandoductin [ Sat Jan 27, 2024 5:57 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
dinasset, here's how I could do it. Code: Select all chosen_setting_name = 'Yellowing Dark Corners' |
Author: | dinasset [ Sat Jan 27, 2024 6:08 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
Tin, this is the current status of the filter I have tested. Attachment: Apart from the specification of the curves presets source (which for me I had to specify as where I have samj's gimp) you can play with it trying to use the input parameter (already specified) as the preset to load. |
Author: | dinasset [ Sat Jan 27, 2024 10:12 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
@tin created a second process inserting what you suggested; inserted traces; it seems that the load loads only 6 presets, then stops Attachment: CatturaTraces.PNG [ 12.32 KiB | Viewed 594 times ] any idea? |
Author: | dinasset [ Sat Jan 27, 2024 10:29 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
If choose to load "Alien", the preset is applied because it is inside the 6 presets read. So, the only thing strange is that the process "load" loads only 6 presets. @ofnuts any idea? |
Author: | ofnuts [ Sat Jan 27, 2024 1:18 pm ] |
Post subject: | Re: use of a color curves preset in a python filter |
dinasset wrote: If choose to load "Alien", the preset is applied because it is inside the 6 presets read. So, the only thing strange is that the process "load" loads only 6 presets. @ofnuts any idea? Can you zip & attach the latest code and settings file? |
Author: | dinasset [ Sat Jan 27, 2024 1:58 pm ] |
Post subject: | Re: use of a color curves preset in a python filter |
Yes, of course. Attachment:
|
Author: | teapot [ Sat Jan 27, 2024 2:50 pm ] |
Post subject: | Re: use of a color curves preset in a python filter |
dinasset wrote: If choose to load "Alien", the preset is applied because it is inside the 6 presets read. So, the only thing strange is that the process "load" loads only 6 presets. Your seventh preset, "Bright Red" is failing in the green channel as it has numbers of format 9.7999999999999997e-05 The regular expression in funtion readChannel didn't support exponents so try changing this: Code: Select all samplesString=extract(r'\(samples \d+ ([0-9. ]+)\)',samplesLine) # skip count value Code: Select all samplesString=extract(r'\(samples \d+ ([-0-9.eE ]+)\)',samplesLine) # skip count value |
Author: | dinasset [ Sat Jan 27, 2024 11:11 pm ] |
Post subject: | Re: use of a color curves preset in a python filter |
Thanks teapot. Changed as indicated and now all presets are browsed. Only left error at end, I will try to understand. |
Author: | dinasset [ Sun Jan 28, 2024 12:34 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
Update: - completed the application of all 5 curves (value, red, green, bue, alpha) here the new zipped program Attachment: Now, because there are incomplete presets(*), I would like to know which statement insert to skip the types absent ("if ...." do not prepare/run the gimp command curves-explicit). As I said, I'm ignorant enough not to know it myself. Thanks for any help. (*) I get always error messages for one channel, different from preset to preset... |
Author: | teapot [ Sun Jan 28, 2024 2:14 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
dinasset wrote: Update: - completed the application of all 5 curves (value, red, green, bue, alpha) here the new zipped program Attachment: python_cc_test2.7z Now, because there are incomplete presets(*), I would like to know which statement insert to skip the types absent ("if ...." do not prepare/run the gimp command curves-explicit). As I said, I'm ignorant enough not to know it myself. Thanks for any help. (*) I get always error messages for one channel, different from preset to preset... Some channels won't be present in the settings data as Ofnuts code doesn't add the identity channels (those that don't do anything as their curve is a straight line from bottom left to top right). Identity channels have this in the GimpCurvesConfig.settings file: points 4 0 0 1 1 e.g. Your preset "Alien" channel value and channel alpha. Therefore your preset "Alien" only has red, green and blue channels in the settings data. So code in your function python_cc_test2 won't work as in hard coding the indices it assumes all channels are present. I'd suggest you have a for loop that goes through the channels like Ofnuts does at the end of his load-colour-curves-preset.py code: for c in s.channels: Or with your variable name for c in chosen_setting.channels: Then use c.name to see which one it is e.g. red and c.samples to get the samples. Unfortunately I'm stuck on an old version of gimp due to hardware issues so can't run your code. (Am hoping for a new computer next month). |
Author: | dinasset [ Sun Jan 28, 2024 2:52 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
Thanks teapot. I'll try to do my best in doing that, later on today. |
Author: | ofnuts [ Sun Jan 28, 2024 3:48 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
teapot wrote: dinasset wrote: Update: I'd suggest you have a for loop that goes through the channels like Ofnuts does at the end of his load-colour-curves-preset.py code: for c in s.channels: Or with your variable name for c in chosen_setting.channels: Then use c.name to see which one it is e.g. red and c.samples to get the samples. Unfortunately I'm stuck on an old version of gimp due to hardware issues so can't run your code. (Am hoping for a new computer next month). And to avoid an "if" you just make a dictionary that map the channel name to the channel constant in the call: Code: Select all channelConstants={ |
Author: | dinasset [ Sun Jan 28, 2024 6:27 am ] |
Post subject: | Re: use of a color curves preset in a python filter |
@ofnuts Wow! Fantastic simplicity. Updated the filter, done just the default test: OKAY. Thanks a lot! I will continue tests with all interesting presets. |
Page 2 of 3 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |