Gimptalk - Premier Gimp Community: Help with first Scheme script - Gimptalk - Premier Gimp Community

Jump to content

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

Help with first Scheme script

#1 User is offline   physiker 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 27-July 11

Posted 27 July 2011 - 11:32 AM

Hello GT members,

I have written a short script (my first one actually) which has to load 5 images as layers and merge them together, in between adding a layer of transparency to some of the images
basically it is intended for be used with GIMP in batch mode via the command line.


(define (overlay-script file1 file2 file3 file4 file5)

(let* (
(gimp-file-load-layer 1 imageMain file1)
(gimp-file-load-layer 1 imageRight (car (plug-in-colortoalpha 1 file2 drawable 000000)))
(gimp-file-load-layer 1 imageTop (car (plug-in-colortoalpha 1 file3 drawable 000000)))
(gimp-file-load-layer 1 imageCenter (car (plug-in-colortoalpha 1 file4 drawable 000000)))
(gimp-file-load-layer 1 imageLeft (car (plug-in-colortoalpha 1 file5 drawable 000000)))) )

(gimp-image-merge-visible-layers NewImage 0)

(gimp-xcf-save 1 NewImage drawable file1 file1))


Upon executing the code (running GIMP 2.6.10 on Ubuntu 10 LTS), I receive the following error:

batch command experienced an execution error 



Any help is appreciated.
Many thanks.

This post has been edited by physiker: 27 July 2011 - 11:45 AM

0

#2 User is offline   paynekj 

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

Posted 27 July 2011 - 03:00 PM

You have a few things wrong

gimp-file-load-layer loads an image into a currently open image as specified by the destination image parameter, so your first step should probably be to open the first image and then add the other images as layers in the first image:

(let* ( (NewImage 0) (layerRight 0))
	(set! NewImage (car (gimp-file-load RUN-NONINTERACTIVE file1 file1)))
	(set! layerRight (car (gimp-file-load-layer RUN-NONINTERACTIVE NewImage file2)))
	(plug-in-colortoalpha RUN-NONINTERACTIVE NewImage layerRight '(0 0 0))
	(gimp-image-add-layer NewImage layerRight -1)   
 )


Also note that you can't do the gimp-file-load-layer inside the let* block as you are then redefining the meaning of gimp-file-load-layer

This post has been edited by paynekj: 27 July 2011 - 03:03 PM

Kevin
0

Share this topic:


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