It is currently Mon Jul 01, 2024 3:44 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: TypeError: could not convert to GimpRGB (Solved)
PostPosted: Fri May 08, 2020 8:50 pm  (#1) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Hi guy it's me again and I'm having trouble recognizing what I'm doing wrong in this script. :gaah
I know that fencepost created a Script-fu script that I used, but his script need it for you to install a scanline pattern.I just created a "Jean (denim) seamless pattern" strictly with no 3rd party add ons. I used the GIMP "Newsprint" plugin instead of a pattern to create the fabric like lines. OK, I'm getting "TypeError: could not convert to GimpRGB", what is this old senile guy :hehe missing?

File "C:\Users\Pocholo\AppData\Roaming\GIMP\2.10\plug-ins\Create a jean texture.py", line 43, in pm_jean__seamless_texture
pdb.gimp_context_set_foreground (fgColor)
TypeError: could not convert to GimpRGB




from gimpfu import *

def pm_jean__seamless_texture(size, fgColor):

   pdb.gimp_context_push()
   size = 500
   #Create the first blue layer
   img = pdb.gimp_image_new(size, size, RGB)
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Jean", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)
   
   #Create a new layer fill with Noise and change the layer mode
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Blue1", 100, LAYER_MODE_GRAIN_MERGE)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)
   pdb.plug_in_hsv_noise(img, layer, 1, 180, 0, 255)
   pdb.gimp_layer_set_mode(layer, LAYER_MODE_GRAIN_MERGE)
   
   #Create a layer and change layer mode
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Blue2", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)   
   pdb.gimp_layer_set_mode(layer, LAYER_MODE_GRAIN_MERGE)
   
   #Create a layer and create the texture
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Texture", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)   
   pdb.gimp_layer_set_mode(layer, LAYER_MODE_MULTIPLY)
   pdb.plug_in_newsprint(img, layer,
                              6,
                              0,
                              0,
                              55,
                              1,
                              55,
                              1,
                              55,
                              1,
                              55,
                              1,
                              50)
   #Merge all layers
   layer = pdb.gimp_image_merge_visible_layers(img, CLIP_TO_BOTTOM_LAYER)
                              
   gimp.Display(img)
   
   pdb.gimp_context_pop()

_________________
https://www.deviantart.com/pocholo17
Image


Last edited by Pocholo on Sat May 09, 2020 2:23 pm, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: TypeError: could not convert to GimpRGB
PostPosted: Fri May 08, 2020 9:18 pm  (#2) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
I had on the define line (size, fgColor) and the script was giving me an error mention above. I thought those were defined. I wrote on the lines below, the size = 500 and fgColor = (51, 112, 172). Now the script is running smoothly.

OK, I did't have to do this in the Heart script that I posted last night. What's the difference?



def pm_jean__seamless_texture(size, fgColor):

   pdb.gimp_context_push()
   
   size = 500
   fgColor = (51, 112, 172)
   
   #Create the first blue layer
   img = pdb.gimp_image_new(size, size, RGB)
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Jean", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)





This is the result

Image

_________________
https://www.deviantart.com/pocholo17
Image


Top
 Post subject: Re: TypeError: could not convert to GimpRGB
PostPosted: Fri May 08, 2020 10:53 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
Hi Pocholo.

Congratulations. :clap
It works without error for me (after deleting the size = 500 entry and adding registration).
It would be easier to try if all the code was included.


Attachments:
Jenim by Pocholo.png
Jenim by Pocholo.png [ 26.21 KiB | Viewed 1633 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: TypeError: could not convert to GimpRGB
PostPosted: Fri May 08, 2020 11:23 pm  (#4) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Thank you MareroQ. Can you explain me how you did it? I'm puzzle! :puzzled


from gimpfu import *

def pm_jean__seamless_texture(size, fgColor):

   pdb.gimp_context_push()
   
   size = 500
   fgColor = (51, 112, 172)
   
   #Create the first blue layer
   img = pdb.gimp_image_new(size, size, RGB)
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Jean", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)
   
   #Create a new layer fill with Noise and change the layer mode
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Blue1", 100, LAYER_MODE_GRAIN_MERGE)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)
   pdb.plug_in_hsv_noise(img, layer, 1, 180, 0, 255)
   pdb.gimp_layer_set_mode(layer, LAYER_MODE_GRAIN_MERGE)
   
   #Create a layer and change layer mode
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Blue2", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)   
   pdb.gimp_layer_set_mode(layer, LAYER_MODE_GRAIN_MERGE)
   
   #Create a layer and create the texture
   layer = pdb.gimp_layer_new(img, size, size, RGB, "Texture", 100, LAYER_MODE_NORMAL)
   pdb.gimp_image_add_layer(img, layer, 0)
   pdb.gimp_context_set_foreground (fgColor)
   pdb.gimp_drawable_fill(layer, FILL_FOREGROUND)   
   pdb.gimp_layer_set_mode(layer, LAYER_MODE_MULTIPLY)
   pdb.plug_in_newsprint(img, layer,
                              6,
                              0,
                              0,
                              55,
                              1,
                              55,
                              1,
                              55,
                              1,
                              55,
                              1,
                              50)
   #Merge all layers
   layer = pdb.gimp_image_merge_visible_layers(img, CLIP_TO_BOTTOM_LAYER)
                              
   gimp.Display(img)
   
   pdb.gimp_context_pop()
   
   
   

register(
   "pm_jean__seamless_texture",
   "Creates a denim texture",
   "Creates a denim seamless texture",
   "Pocholo",
   "Pocholo",
   "2020",
   "Jean texture",
   "",

[
   
   (PF_COLOR, "fgcolor", "Texture color", (51, 112, 172)),
   (PF_SPINNER, "size", "Texture size", 500, (100, 1000, 1)),

],

[],
pm_jean__seamless_texture, menu="<Image>/Python-Fu/Jean texture")

main()   

_________________
https://www.deviantart.com/pocholo17
Image


Top
 Post subject: Re: TypeError: could not convert to GimpRGB
PostPosted: Sat May 09, 2020 12:33 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
You changed the order of PF_SPINNER, "size", with PF_COLOR, "fgcolor" (they must appear in the order in the definition), I removed unnecessary spaces in the registration (according to the attachment),
I commented on:
#size = 500
#fgColor = (51, 112, 172)

Do you use Notepad ++?

ps. Don't forget about #!/Usr/bin/env python.


Attachments:
P1 Error.png
P1 Error.png [ 8.37 KiB | Viewed 1619 times ]
P2 OK.png
P2 OK.png [ 7.68 KiB | Viewed 1619 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: TypeError: could not convert to GimpRGB
PostPosted: Sat May 09, 2020 1:01 am  (#6) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Something so simple and yet for me a newbie, so hard. Thank you my friend owe you! Be safe. By the way, yes I use noterpad++.

_________________
https://www.deviantart.com/pocholo17
Image


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Python-fu gimp_drawable_levels(): "TypeError: wrong parameter type"

2

No new posts Attachment(s) convert a gbr bristles to abr

2

No new posts Attachment(s) Can someone please convert these two python scripts for Gimp 2.99.19

10

No new posts Convert a selection into an array of coordinates/points

2

No new posts Convert GIMP plugin from Python 2 to Python 3

4



* Login  



Powered by phpBB3 © phpBB Group