Gimptalk - Premier Gimp Community: script-fu problem with map-object - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

script-fu problem with map-object

#1 User is offline   bertram79 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 18-July 10

Posted 18 July 2010 - 12:30 PM

Hi,
complete beginner with script-fu, but I have not been able to find a specific solution to my problem in the forums. I run a script which applies the map-object filter to an image. It works fine up until the point when I want to save the image. The problem is that map-object opens a new file for the output. So my questions is: how do either prevent this plug-in from opening a new image, or how do I save the new image with my script?

My code looks like this:
(define (pbe-wireframe size res)
 (let* (
        (my_image (car (gimp-image-new size size RGB)))
        (my_layer (car (gimp-layer-new my_image size size RGB-IMAGE "Wireframe" 0 NORMAL)))
       )
  (gimp-image-add-layer my_image my_layer 0)
  (gimp-context-set-background '(255 255 255))
  (gimp-drawable-fill my_layer BACKGROUND-FILL)
  (plug-in-checkerboard RUN-NONINTERACTIVE my_image my_layer 0 res)
  (plug-in-edge RUN-NONINTERACTIVE my_image my_layer 2 1 0)
  (plug-in-map-object RUN-NONINTERACTIVE my_image my_layer 1 1 1 1 0 0 0
                      1 1 1 0 0 0 1 1 1 2
                      '(255 127 0) 1 1 1 0 0 0 0 0 0
                      0 0 FALSE FALSE FALSE TRUE 1 10 10 10
                      0 -1 -1 -1 -1 -1 -1 -1 -1)

  (gimp-file-save RUN-NONINTERACTIVE my_image my_layer "C:\\Users\\pbe\\Pictures\\sphere\\sfu\\tst.jpg" "C:\\Users\\pbe\\Pictures\\sphere\\sfu\\tst.jpg")

 )
)

(script-fu-register "pbe-wireframe"
                    "Wireframe"
                    "Creates a Wireframe"
                    "P.B."
                    "P.B."
                    "2010-07-18"
                    ""
                    SF-VALUE "size" "100"
                    SF-VALUE "res" "5"
                    SF-COLOR "color" '(000 000 000))
(script-fu-menu-register "pbe-wireframe" "/Xtns/AAA_scripts")


The result is that it saves only the image as it is before the map-object line, and the generated sphere is shown in the graphical output.

All help greatly appreciated!
0

#2 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 18 July 2010 - 12:43 PM

Quote

how do either prevent this plug-in from opening a new image, or how do I save the new image with my script?


i left to the script-fu guru visiting this board a answer to question 2

About question 1, that is simple, to avoid that the active layer must have a alpha channel
So check for alpha, and add it if missing should fix

(maybe there is a rude way to avoid errors.. set in the script as requirement for image type "RGBA"
but that will not add the alpha,but in case of RBG should pop out a error message that will give a clue to advanced users on what went wrong )
0

#3 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 18 July 2010 - 01:00 PM

PS i notice 2 errors here (i am not a script fu guru the only part of a script i understand is this; the registration block )

Quote

(script-fu-register "pbe-wireframe"
"Wireframe"
"Creates a Wireframe"
"P.B."
"P.B."
"2010-07-18"
""
SF-VALUE "size" "100"
SF-VALUE "res" "5"
SF-COLOR "color" '(000 000 000))
(script-fu-menu-register "pbe-wireframe" "/Xtns/AAA_scripts")

1) ""
if "" is the image type that is wrong, currently your script could only work (if are no other errors ) with "RGBA"
With my suggestion (adding a alpha channel to the active layer first ) that should be "RGB RGBA"

In any case the script will never work with index or greyscale images, because are not supported by the M.O plugin


2)(script-fu-menu-register "pbe-wireframe" "/Xtns/AAA_scripts

Are you making script for very obsolete version of gimp?

from gimp 2.4 there are no more menus in the Toolbox (neither may be added)

So in the best case your script would be remapped in some weird place (i suppose in /File/New/AAA_scripts ) in the worst will not show up at all

You should correct that in something as /Filters/.../AAA_scripts
0

#4 User is offline   paynekj 

  • Member
  • PipPip
  • Group: Members
  • Posts: 317
  • Joined: 01-June 05
  • LocationUK

Posted 19 July 2010 - 09:10 AM

There's a couple of other things wrong:

when you create the new layer, you specify the mode to be RGB-IMAGE, but you then go on to run the map-object with transparency set to true, which isn't possible with a RGB image. You need to have an alpha channel, so the mode needs to be RGBA-IMAGE. On the same new layer command you have set the opacity of the new layer to 0 - i.e. invisible. Did you really mean that?

So I end up with a line like this:
(my_layer (car (gimp-layer-new my_image size size RGBA-IMAGE "Wireframe" 100 NORMAL)))

I also had to add a line to make it visible:
(gimp-display-new my_image)

Finally, you're saving it as a .jpg, but jpegs don't support transparency.

Hope this helps

Kevin
0

#5 User is offline   bertram79 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 18-July 10

Posted 20 July 2010 - 06:16 PM

Thanks a lot for your help! It works nicely now.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic