Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
perl script
#1
Hi,

Does someone please know how to change a color in a gimp image, but doing this through perl script ?

Changing a channel color would be prefect !

I don't find exactly this information on metacpan (Gimp ; Gimp:Fu).


Regards  Smile

Aka
Reply
#2
(09-16-2021, 09:39 AM)aka Wrote: ..snip..Does someone please know how to change a color in a gimp image, but doing this through perl script ?
Changing a channel color would be prefect !

You are not going to get a gimp perl script to work without a gimp-perl module. The last time I used this was with PClinuxOS maybe 10 or 12 years ago, even then it was unusual to keep that package in the repo.  Really it went out with Gimp 2.2 / 2.4

If you want to try your hand at compiling then the source is here: https://github.com/GNOME/gimp-perl Edit: interesting, updated for Gimp 2.10

All sorts of non-perl ways to change colours in an image, give details and I am sure there will be recomendations.
Reply
#3
Thanks,

I know now how to get a channel :

$image->get_channels

Do you know how to change the color of this channel, please ? I don't find it..

Best regards
Reply
#4
(09-18-2021, 06:28 AM)aka Wrote: Thanks,

I know now how to get a channel :

$image->get_channels

Do you know how to change the color of this channel, please ? I don't find it..

Best regards

What do you mean by "change the color"? A channel is a monochrome thing... This said, a channel is a "drawable" so many "Color tools" work on it (as if it were a layer): Levels, Threshold, etc...
Reply
#5
Hi,

It can be a channel, a layer, or an other mean ; I can adapt the structure of the gimp image to the choosen mean.

See please a sample, the jointed image : I would like, through a script, change the color of the 2 red lines (but not the red little circle). So, I have in this sample done 4 layers, one of them ("layer2") contains only these 2 red lines.

If a "get the layer2" and "change its color", I have reached my purpose  Smile


Attached Files
.xcf   sample.xcf (Size: 36.07 KB / Downloads: 176)
Reply
#6
I don't know perl, but in scheme or python, excatly as you would do it manually:

Code:
# Ensure the layer is alpha-locked (so we don't paint the transparent pixels)
pdb.gimp_layer_set_lock_alpha(layer, True)
# Set foreground to wanted color
pdb.gimp_context_set_foreground((0,0,255))
# Bucket-fill the selection (there should be no selection)
pdb.gimp_drawable_edit_fill(layer,FILL_FOREGROUND)

   

To get layer2, you can either use its position in the stack, or enumerate all the layers and compare the names.
Reply


Forum Jump: