Share this topic on AskShare this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on TwitterShare this topic on YahooShare this topic on Google buzz

Author Topic: [Script-Fu] Hidden Watermarks  (Read 1252 times)

0 Members and 1 Guest are viewing this topic.

Offline fencepost

  • Member
  • **
  • Posts: 2,626
  • Karma: 0
    • fence-post.deviantart.com
[Script-Fu] Hidden Watermarks
« Reply #60 on: March 28, 2010, 05:17:17 PM »
I added an offset option.  Ran it through the settings and appears to work fine.  This will be the last feature I'm gonna add to the script (I may, someday, put in an option to open/save to other formats), but I think this is a pretty good script as is.

Code: [Select]
(define (fp-script-fu-watermark load location filename pattern position x y color opacity azimuth elevation depth waterlevel ambient compensate invert type hblur vblur hidePattern hideOpacity)

(let* (

(filelist (cadr (file-glob (string-append load  DIR-SEPARATOR "*.[jJ][pP][gG]") 1)))
(s 1)
(count (car (file-glob (string-append load  DIR-SEPARATOR "*.[jJ][pP][gG]") 1)))
(drawable 0)
(patWidth (car (gimp-pattern-get-info pattern)))
(patHeight (cadr (gimp-pattern-get-info pattern)))
(patLayer 0)
(patLayer2 0)
(active 0)
(bumpLayer 0)
(filename2 0)
(offsetX (+ 0 x))
(offsetY (+ 0 y))
(imageWidth 0)
(imageHeight 0)


)





(while (pair? filelist)
(let* (
(loadfile (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE loadfile loadfile)))
)


(set! imageWidth (car (gimp-image-width image)))
(set! imageHeight (car (gimp-image-height image)))


(cond
  ( (= position 1) ; top right
(set! offsetX (- (- imageWidth patWidth) x))
  )

( (= position 2) ; center
(set! offsetX (- (/ imageWidth 2) (/ patWidth 2)))
  (set! offsetY (- (/ imageHeight 2) (/ patHeight 2)))
)


( (= position 3) ; bottom left
(set! offsetY (- (- imageHeight patHeight) y))
)

  ( (= position 4) ; bottom right
(set! offsetX (- (- imageWidth patWidth) x))
(set! offsetY (- (- imageHeight patHeight) y))
  )

)


(gimp-context-push)
(set! bumpLayer (car (gimp-image-get-active-layer image)))
(set! patLayer2 (car (gimp-layer-copy bumpLayer TRUE)))
(gimp-context-set-pattern hidePattern)
(gimp-drawable-fill patLayer2 TRANSPARENT-FILL)
(gimp-drawable-fill patLayer2 PATTERN-FILL)
(gimp-image-add-layer image patLayer2 -1)
(gimp-layer-set-opacity patLayer2 hideOpacity)



(set! patLayer (car (gimp-layer-new image patWidth patHeight RGBA-IMAGE "Pattern Layer" 100.0 NORMAL-MODE)))
(gimp-drawable-fill patLayer TRANSPARENT-FILL)
(gimp-context-set-pattern pattern)
(gimp-drawable-fill patLayer PATTERN-FILL)
(gimp-image-add-layer image patLayer -1)
(gimp-layer-set-offsets patLayer offsetX offsetY)
(gimp-layer-set-lock-alpha patLayer TRUE)
(gimp-context-set-foreground color)
(gimp-edit-fill patLayer FOREGROUND-FILL)

(gimp-layer-resize-to-image-size patLayer)
(plug-in-gauss-rle2 RUN-NONINTERACTIVE image patLayer hblur vblur)
(plug-in-bump-map RUN-NONINTERACTIVE image bumpLayer patLayer azimuth elevation depth 0 0 waterlevel ambient compensate invert type)
(gimp-layer-set-opacity patLayer opacity)
(set! active (car (gimp-image-flatten image)))
(set! filename2 (string-append location DIR-SEPARATOR filename (number->string s) ".jpg"))
(gimp-file-save RUN-NONINTERACTIVE image active filename2 filename2)
(set! s (+ s 1))


(gimp-image-delete image)
(set! count (- count 1))
(set! filelist (cdr filelist))

))

(gimp-context-push)
)
)
(script-fu-register "fp-script-fu-watermark"
"<Image>/File/Watermark..."
"Adds a bump mapped watermark to a folder of jpg images."
"Art Wade"
"Art Wade"
"March 2010"
""

SF-DIRNAME   "Load pictures from" ""
SF-DIRNAME     "Save pictures to" ""
    SF-STRING     "Name for watermarked images" "filename"
SF-PATTERN    "Pattern to use as bump map watermark" "Watermark"
SF-OPTION     "Watermark position" '("Upper Left" "Upper Right" "Center" "Lower Left" "Lower Right")
SF-ADJUSTMENT "Watermark edge x offset" '(0 0 100 1 1 0 1)
SF-ADJUSTMENT "Watermark edge y offset" '(0 0 100 1 1 0 1)
SF-COLOR      "Watermark color" '(255 255 255)
SF-ADJUSTMENT "Watermark opacity" '(50.0 0.0 100.0 1 10 1 0)
SF-ADJUSTMENT "Bump map azimuth" '(50.0 0.0 360.0 1 10 1 0)
SF-ADJUSTMENT "Bump map elevation" '(45.0 0.5 90.0 1 10 1 0)
SF-ADJUSTMENT "Bump map depth" '(2 1 65 1 10 0 0)
SF-ADJUSTMENT "Bump map waterlevel" '(100 0 255 1 10 0 0)
SF-ADJUSTMENT "Bump map ambient" '(0 0 255 1 10 0 0)
SF-TOGGLE   "Bump map compensate for darkening" TRUE
SF-TOGGLE   "Bump map invert" FALSE
SF-OPTION     "Bump map type" '("LINEAR" "SPHERICAL" "SINUSOIDAL")
SF-ADJUSTMENT "Bump map horizontal blur" '(1.0 0.1 15.0 1 10 1 0)
SF-ADJUSTMENT "Bump map vertical blur" '(1.0 0.1 15.0 1 10 1 0)
SF-PATTERN   "Pattern to use for hidden watermark" "Watermark"
SF-ADJUSTMENT "Hidden watermark opacity" '(3.5 0.1 10.0 1 1 1 0)


)
I'd rate you as an upper-middle-lower-mod with pro-novice-inter tendencies.....and a twist of lime!  Of course, my rating scale is completely objectively subjective, but ALWAYS consistently inconsistent.

Offline Darth_Gimp

  • Number One
  • *****
  • Posts: 2,833
  • Karma: 0
  • Faith, Folk, Family!
    • lds-jedi.deviantart.com
    • Odinic Rite
[Script-Fu] Hidden Watermarks
« Reply #61 on: March 28, 2010, 05:20:11 PM »
Awesome work there Fence.. if only it came with Scarlet Johansson's private phone number.. then it would be even more awesomer.  :D Just playin.
GimpDome Group: http://gimpdome.deviantart.com/
My DeviantArt: http://lds-jedi.deviantart.com/

There's no worse feeling than that millisecond you're sure you are going to die after leaning your chair back a little too far.

Offline gimprotect

  • Member
  • **
  • Posts: 51
  • Karma: 0
[Script-Fu] Hidden Watermarks
« Reply #62 on: March 28, 2010, 11:59:45 PM »

I added an offset option.  Ran it through the settings and appears to work fine.
This will be the last feature I'm gonna add to the script (I may, someday, put in an option to open/save to other formats), but I think this is a pretty good script as is.

I really don´t know how I could possibly pay back my tribute to all the work you put into this script. Maybe I´m able to code scripts later on myself and can help you improving it even more - and once a feature is implemented people like me keep requesting about stuff (I know how that feels).

You´ve successfully coveyed that you KNOW what you´re talking about and for sure you might have learned a bunch of useful things yourself...

Fencepost, THANK YOU. 

-gimprotect
« Last Edit: March 29, 2010, 08:39:10 AM by gimprotect »
Check it Out: Hidden Watermarks in GIMP Thanks fence!

Offline fencepost

  • Member
  • **
  • Posts: 2,626
  • Karma: 0
    • fence-post.deviantart.com
[Script-Fu] Hidden Watermarks
« Reply #63 on: March 30, 2010, 06:55:35 AM »
Well, I'm glad that the script has been helpful and hope it is a useful resource for you in the future.  I would suggest that you create your own watermarks simply because they should reflect your personality and needs.  While I plan on add in the option to open/save in other formats, right now, I've got too many other things to out.

Glad to have been of assistance and hope to see you as a regular here at the dome.

Art
« Last Edit: March 30, 2010, 09:20:41 AM by fencepost »
I'd rate you as an upper-middle-lower-mod with pro-novice-inter tendencies.....and a twist of lime!  Of course, my rating scale is completely objectively subjective, but ALWAYS consistently inconsistent.

Offline gimprotect

  • Member
  • **
  • Posts: 51
  • Karma: 0
Re: [Script-Fu] Hidden Watermarks
« Reply #64 on: March 30, 2010, 04:05:13 PM »

I would suggest that you create your own watermarks simply because they should reflect your personality and needs.

Oh, already did that during the development process and the various bug fixes. Works so awesome flawlessly, can´t even believe it!

While I plan on add in the option to open/save in other formats, right now, I've got too many other things to out.

That just life. Keep it in mind, but don´t go crazy over it. As long as it works out perfectly with jpegs, most people should be happy.

Glad to have been of assistance and hope to see you as a regular here at the dome.

Are you serious thinking I wouldn´t come back? YOU BET I DO!  So far I really enjoyed my membership here, let´s see what comes next!

Oh, there´s one thing I´d like to share with everyone as well: Two days ago I thought to have found another error in the script (picture turned black while inverting the bump map), but as I found out minutes later that wasn´t the case - I simply accidentally unticked "compensate for darkening". In between the discovery of the "error" and my own "fix" I wrote a message to Darth_Gimp asking him if he could assist me to tell you that there´s another "error". He replied in a friendly tone that he won´t "lie" to you simply because he respects you both as a member and as a good friend. My fear was to ask you again of another favour bacause you´ve done so much for me already until Darth gave me a nudge to tell me that´s the wrong way. To conclude: I`ll tell you straight into the face next time and I very much appreciate Darth_Gimps effort to make me aware of it. Thanks, Darth!

-gimprotect
« Last Edit: March 30, 2010, 04:09:03 PM by gimprotect »
Check it Out: Hidden Watermarks in GIMP Thanks fence!


Tags: