It is currently Mon Jun 08, 2026 11:33 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: help with this needed
PostPosted: Tue May 08, 2012 2:23 am  (#1) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
GIMP Version: 2.6.11
Operating System: Windows
OS Version: XP - SP3
GIMP Experience: Beginner Level



Can someone thow some light on this problem, script works but attached batch file does not

(define (script-fu-watermark-batch
srcpath destpath wmfile xmargini ymargini opai wmtext xmargint ymargint opat opatb wmfont wmfontsize wmfontcolor wmnocolor wmemboss toplef toprig botlef botrig centered)
  (let*
    (
      (flatten 1)
      (filepattern "*.jpg")
      (pathpattern (string-append srcpath filepattern))
      (filelist (cadr (file-glob pathpattern 1)))
    )
    (while (not (null? filelist))
      (let*
        (
          (filename (car filelist))
          (dirs (strbreakup filename "/"))
          (depthofpath (length dirs))
          (shortfilename (nth (- depthofpath 1) dirs))
          (destfilename (string-append destpath shortfilename))

          (imagelist (gimp-file-load RUN-NONINTERACTIVE filename filename))
          (image (if (not (null? imagelist)) (car imagelist) 0))
          (drawablelist (gimp-image-get-active-layer image))
          (drawable (if (not (null? drawablelist)) (car drawablelist) 0))
        )

        (if (> drawable 0)
          (begin
            (script-fu-watermark-it
             image drawable wmfile xmargini ymargini opai wmtext xmargint ymargint opat opatb wmfont wmfontsize wmfontcolor wmnocolor wmemboss toplef toprig botlef botrig centered)
            (set! drawable (car (gimp-image-get-active-layer image)))
            (gimp-file-save RUN-NONINTERACTIVE image drawable destfilename shortfilename)
            (gimp-image-delete image)
          )
        )
      )
      (set! filelist (cdr filelist))
    )
  )
)

(script-fu-register
  "script-fu-watermark-batch"
  "<Toolbox>/Script-Fu/Batch Tools/Watermark Batch..."
  "Batch processes the jpg files located at 'Source Path' with the script-fu Watermark-it.
  Saves the results at 'Destination Path'."
  "T. Demand <td-e.com>"
  "T. Demand"
  "2007.11.12"
  ""
  SF-DIRNAME      "Source Path"        ""
  SF-DIRNAME      "Destination Path"   ""
  SF-FILENAME      "Watermark image--------------" "/home/~username/Pictures/wm/c104.png"
  SF-ADJUSTMENT  "Image X margin"     '(10 0 250 1 10 0 1)
  SF-ADJUSTMENT  "Image Y margin"     '(10 0 250 1 10 0 1)
  SF-ADJUSTMENT  "Image opacity"      '(60 1 100 1 10 0 1)
  SF-STRING      "Watermark text------------------" "(c)2012 Author Name"
  SF-ADJUSTMENT  "Text X margin"      '(20 0 250 1 10 0 1)
  SF-ADJUSTMENT  "Text Y margin"      '(20 0 250 1 10 0 1)
  SF-ADJUSTMENT  "Text opacity"       '(90 1 100 1 10 0 1)
  SF-ADJUSTMENT  "Text perimeter opacity" '(40 0 100 1 10 0 1)
  SF-FONT        "Font"               "FreeSans Bold"
  SF-ADJUSTMENT  "Font Size (pixels)" '(20 6 1000 1 10 0 1)
  SF-COLOR       "Font color"         '(255 208 128)
  SF-TOGGLE      "No color i.e. lighten or darken image" FALSE
  SF-TOGGLE      "Emboss Text"        TRUE
  SF-OPTION      "TOP-LEFT"           '("No Watermark" "Image Watermark" "Text Watermark")
  SF-OPTION      "TOP-RIGHT"          '("No Watermark" "Image Watermark" "Text Watermark")
  SF-OPTION      "BOTTOM-LEFT"        '("No Watermark" "Image Watermark" "Text Watermark")
  SF-OPTION      "BOTTOM-RIGHT"       '("No Watermark" "Image Watermark" "Text Watermark")
  SF-OPTION      "CENTER"             '("No Watermark" "Image Watermark" "Text Watermark")
)


Attachment:
Watermark it.scm [13 KiB]
Downloaded 111 times

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


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: help with this needed
PostPosted: Tue May 08, 2012 3:48 am  (#2) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
What command are you using to invoke the script?

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: help with this needed
PostPosted: Tue May 08, 2012 6:48 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
Saulgoode I can only presume 'OK' as it disapears below screen on my laptop

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: help with this needed
PostPosted: Tue May 08, 2012 8:13 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
I found this snippet hope it helps but still can't get to work in 2-6-12 win7
Date:
Tuesday 16 September 2008
Time:
20:43:24 UTC
Author:
Rodrigo
watermark-batch in windoze
The script works great in Ubuntu 8.04.
When I tried to use watermark-batch in windoze, after selecting all parameters and pressing the OK button nothing happened. I guessed it was something about path names, so I changed
(dirs (strbreakup filename ʼ/ʼ))
by
(dirs (strbreakup filename ʼ\\ʼ))
Now the script works fine in windoze.
Be sure to type full source and destination paths. For example:
Source Path: c:\source\
Destination Path: c:\dest\

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: help with this needed
PostPosted: Wed May 09, 2012 1:09 am  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
What saulgoode asked was what command line you typed in to start the batch script, but I'm guessing that your resposnse "OK" means that you are starting this from a menu item within GIMP ?

As that (rather difficult to read - please don't centre-justify text) comment you've posted says, it has been written to work on Linux rather than be cross-platform.
Change the line in script-fu-watermark-batch that reads (dirs (strbreakup filename "/")) to (dirs (strbreakup filename DIR-SEPARATOR))

I'll try it later, because I'm not convinced that it will work - the destfilename looks like it's being composed wrongly.

Kevin


Top
 Post subject: Re: help with this needed
PostPosted: Wed May 09, 2012 3:32 am  (#6) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I've found three things wrong, all due to the same error:

The line that reads:
(pathpattern (string-append srcpath filepattern))

Should be:
(pathpattern (string-append srcpath DIR-SEPARATOR filepattern))


The line that reads:
(dirs (strbreakup filename "/"))

Should be:
(dirs (strbreakup filename DIR-SEPARATOR))


And the line that reads:
(destfilename (string-append destpath shortfilename))

should read:
(destfilename (string-append destpath DIR-SEPARATOR shortfilename))


(define (script-fu-watermark-batch
srcpath destpath wmfile xmargini ymargini opai wmtext xmargint ymargint opat opatb wmfont wmfontsize wmfontcolor wmnocolor wmemboss toplef toprig botlef botrig centered)
  (let*
    (
      (flatten 1)
      (filepattern "*.jpg")
      (pathpattern (string-append srcpath DIR-SEPARATOR filepattern))
      (filelist (cadr (file-glob pathpattern 1)))
    )
    (while (not (null? filelist))
      (let*
        (
          (filename (car filelist))
          (dirs (strbreakup filename DIR-SEPARATOR))
          (depthofpath (length dirs))
          (shortfilename (nth (- depthofpath 1) dirs))
          (destfilename (string-append destpath DIR-SEPARATOR shortfilename))

          (imagelist (gimp-file-load RUN-NONINTERACTIVE filename filename))
          (image (if (not (null? imagelist)) (car imagelist) 0))
          (drawablelist (gimp-image-get-active-layer image))
          (drawable (if (not (null? drawablelist)) (car drawablelist) 0))
        )

        (if (> drawable 0)
          (begin
            (script-fu-watermark-it
             image drawable wmfile xmargini ymargini opai wmtext xmargint ymargint opat opatb wmfont wmfontsize wmfontcolor wmnocolor wmemboss toplef toprig botlef botrig centered)
            (set! drawable (car (gimp-image-get-active-layer image)))
            (gimp-file-save RUN-NONINTERACTIVE image drawable destfilename shortfilename)
            (gimp-image-delete image)
          )
        )
      )
      (set! filelist (cdr filelist))
    )
  )
)


And you probably want to change the line in the script-fu-register "script-fu-watermark-batch" that gives the location of the watermark image:
SF-FILENAME      "Watermark image--------------" "/home/~username/Pictures/wm/c104.png"

because it always throws an error when I run the script.

Kevin


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group