You are here

Image subtraction script

Can someone help me please? Am a complete newbie to Script-Fu... I just need to make a script based on the "image-subtraction" plug-in ( ). The script should 'image subtract' back.jpeg from photoin.jpeg using a threshold of 30 and save the result to photoout.jpeg.
I've come up with:

(define (photo-mask input backer output)

(let* ((image (car (file-jpeg-load RUN-NONINTERACTIVE input input)))
(imageBack (car (file-jpeg-load RUN-NONINTERACTIVE backer backer)))
(drawableM (car (gimp-image-get-active-drawable image)))
(drawableS (car (gimp-image-get-active-drawable imageBack)))
(imageOut (car (image-subtraction RUN-NONINTERACTIVE image drawableM drawableS 30)))
(drawableOut (car (gimp-image-get-active-drawable imageOut))))

(file-jpeg-save RUN-NONINTERACTIVE imageOut drawableOut output output 0.8 0 1 1 "" 0 1 0 0))


But when I call this with :

(photo-mask "c:\photoin.jpeg" "c:\back.jpeg" "c:\photoout.jpeg")

I get...
Error: Procedure execution of image-subtraction failed on invalid input arguments

Parameters for the image-subtraction plug-in are supposed to be :
run-mode INT32 Interactive, non-interactive
image IMAGE Input image
drawable DRAWABLE Master drawable
drawable DRAWABLE Slave drawable
threshold INT32 Threshold

I expect the main problem is my complete lack of Script-Fu knowledge , I've looked through lots of tutorials but just need a little bit of help with this ....

Thanks in anticipation...

There is a problem with the way you are calling the script.

(photo-mask "c:\photoin.jpeg" "c:\back.jpeg" "c:\photoout.jpeg")

The backslash is used in Script-fu to escape special characters appearing in text strings (such as \" to include a quote or \n to include a newline). If you actually want a backslash to appear in the string, you should use two backslashes (\\).

(photo-mask "c:\\photoin.jpeg" "c:\\back.jpeg" "c:\\photoout.jpeg")

Subscribe to Comments for "Image subtraction script"