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 6577 times)

0 Members and 1 Guest are viewing this topic.

Offline gimprotect

  • Member
  • **
  • Posts: 51
  • Karma: 0
[Script-Fu] Hidden Watermarks
« on: March 19, 2010, 06:55:33 AM »

Thanks for your rapid response, fencepost!

Someone on the flickr board already created a script that can be downloaded here: http://gimp-scripts.googlecode.com/files/wm-text.scm

Seems to be the same I previously discovered. See, I have an album with 200+ pictures I´d like to publish - and that script cannot handle an album.
Furthermore I´m not sure whether it really does what your post is intendet to do due to the fact that upon applying it, I can´t find the patched image.

I also got your PM and will look into incorporating a bump map option to the script; shouldn't be too difficult to add.

That would be AWESOME if you did! Please integrate an option to set opactity, shade and maybe even colorization as well. You rock!
  :h_star:



Posted on: March 15, 2010, 09:27:51 AM
Quote from: fencepost
The biggest programming issue for me is opening/modifying/saving several images.  I've never been successful trying to get that to work.

The above is part of a PM I received from fencepost. So, first task would be to modify THIS SCRIPT to be able to load a whole folder with the images (no limit) to be watermarked. I´d love to see your partcipation to make this a (smaller) community project.

If this task has been successfully completed and tested, please post a link to the new script to jump to the next task.

THANK YOU for helping me with this, guys!  :)

-gimprotect
« Last Edit: March 19, 2010, 06:58:20 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 #1 on: March 19, 2010, 12:13:41 PM »
I'm working on a test script right now, but since Windows isn't playing nice with opening directories, I'm trying to prepare a script that will work in Windows and then use coding that I'm pretty sure works in Linux.  This is going to have to be done in phases and I will ask that you test my script in steps to make sure it works. 

Will you always be loading jpgs and saving as jpgs or does the script need to be able to open/save in other formats?  Because of the difficulty I'm having, I would like to limit the script to jpgs only.  Is that ok?
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
[Script-Fu] Hidden Watermarks
« Reply #2 on: March 19, 2010, 01:14:55 PM »

Will you always be loading jpgs and saving as jpgs or does the script need to be able to open/save in other formats? 
Because of the difficulty I'm having, I would like to limit the script to jpgs only.  Is that ok?

NO. Of course it is!  ;) (maybe other formats can be added later on) Thanks for working on it, I´d be more than happy to help you testing stuff.

Have a warm n' shiny weekend!

-gimprotect
« Last Edit: March 19, 2010, 01:17:29 PM 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 #3 on: March 22, 2010, 07:36:09 AM »
I had a little time to work on the script last night and will try this evening to post something for you to test.  Right now, I'm working on the Bump Map portion.  Are you wanting to specify certain bump map parameter values or are you ok with those presented in the tutorial?  This first part will choose all the images in the specified file, add the watermark at the chosen location (top left/right, bottom left/right, or center), color it using the chosen color, bump map the image and display it.  The display part is only for testing and will be removed from the final script.

The most difficult thing is the saving process.  I haven't tried saving images with scripts before so I'm not sure of the exact mechanism, but because you'll be doing lots of images, I'm sure you'll have certain "defaults" that you want to be carried out.  Once I get to that point, you and I can work out the details, if there are any.

Let me know about the bump map parameters.  If you want me to use the defaults from the tutorial, I'll plug them right in.  Otherwise, I'll add widgets to the script where you can add them.

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
[Script-Fu] Hidden Watermarks
« Reply #4 on: March 22, 2010, 10:15:40 AM »

Are you wanting to specify certain bump map parameter values or are you ok with those presented in the tutorial?

Really cool would be, if one could resize the bump-map image through drag and drop. Now, I realize that this might be too much work to integrate.
I´d rather prefer to have have the option of being able to plug my own values into the script AND have the option of using the default tutorial-values as well. Is such even possible? Will there be such thing as a small bump-map preview to see the changes while plugging the values manually?

This first part will choose all the images in the specified file, add the watermark at the chosen location (top left/right, bottom left/right, or center), color it using the chosen color, bump map the image and display it.

Thank you for integrating the option of colourization! I also dreamed of being able to adjust the "strength" of the bump - meaning to be able to scale how much it shows up as a bump or is "imprinted" like a stamp into the picture. Please let me know what´s possible to you, I don´t want you to get mad at me for having such incredibly wild imaginations.  ;) Oh, and @ everyone else here: Feel free to toss some ideas and/or criticism at me.

Love and only love,

-gimprotect
« Last Edit: March 22, 2010, 10:58:36 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 #5 on: March 22, 2010, 11:47:29 AM »
Really cool would be, if one could resize the bump-map image through drag and drop. Now, I realize that this might be too much work to integrate.

That would be cool, but unfortunately, it's not possible with scripting.  That would require a plugin and, although learning how to program in C is on my list for this year, I'm not there yet.

Quote
I´d rather prefer to have have the option of being able to plug my own values into the script AND have the option of using the default tutorial-values as well. Is such even possible?

Yes, that's possible and won't be difficult to do at all.  It will be a simple "toggle" switch, such as: "Use default values" or "Modify Values Interactively."  Depending on your choice, the script will run accordingly.

Quote
Will there be such thing as a small bump-map preview to see the changes while plugging the values manually?

I think I can code it as such.  Without getting into the details too much, scripts generally don't allow previews like plugins do.  But, in scripts, when you modify parameters interactively, such as the bump map options, if there is a preview window within plugin being called, then a preview will appear.  Since we will be interactively calling the bump map plugin and there is a preview within it, you'll see a preview.  However, because we are doing this in a workaround fashion, you'll have to have an image open to run the script.  The script will create a dummy copy of your image, you'll set the parameters of the bump map options, the script will run once on the dummy image to "implant" the parameters within GIMP, delete the dummy copy, then finally open up the desired folder and ultimately run the script using the "implanted" settings you used on the dummy copy.

This may sound like a lot of work (it will happen seamlessly on your end), but it's not too bad as far as the coding part.  The main drawback, is that you have to have an image open in GIMP.

Quote
Thank you for integrating the option of colourization! I also dreamed of being able to adjust the "strength" of the bump - meaning to be able to scale how much it shows up as a bump or is "imprinted" like a stamp into the picture.

No problem.  It's really one of the simplest parts of the script.

Quote
Please let me know what´s possible to you, I don´t want you to get mad at me for having such incredibly wild imaginations.

I'll let you know what I can and can't do.  Keep in mind that the more ideas you have, the more time it will take and, as I explained in my PM, free time is not in large supply for me at the moment.
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
[Script-Fu] Hidden Watermarks
« Reply #6 on: March 22, 2010, 12:02:31 PM »

Yeehaa! Great to hear that most of my suggestions are actually not just some tough illusions..  8)

Keep in mind that the more ideas you have, the more time it will take and, as I explained in my PM, free time is not in large supply for me at the moment.

Word. That should be it for now - I´d be happy to help you testing "pre-release versions" of the new script. Please send them via PM. Thanks!

-gimprotect
« Last Edit: March 22, 2010, 12:03:55 PM by gimprotect »
Check it Out: Hidden Watermarks in GIMP Thanks fence!

Offline Darth_Gimp

  • Number One
  • *****
  • Posts: 2,894
  • Karma: 0
  • Faith, Folk, Family!
    • lds-jedi.deviantart.com
    • Odinic Rite
[Script-Fu] Hidden Watermarks
« Reply #7 on: March 22, 2010, 12:18:46 PM »
Fence you should get some pay out of this..
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 #8 on: March 23, 2010, 06:59:27 AM »

Fence you should get some pay out of this..

I absolutely agree with you. Fence, once the script is ready to be released, feel free to drop some suggestions via PM for a possible favour in return.

Love and only love,

-gimprotect
« Last Edit: March 23, 2010, 07:02:25 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 #9 on: March 23, 2010, 07:58:33 AM »
Fence you should get some pay out of this..

I absolutely agree with you. Fence, once the script is ready to be released, feel free to drop some suggestions via PM for a possible favour in return.

No worries.  I like to help and this has been a good learning process for me.  I even found out that the two Windows machines I'm working on don't respond to the script the same.  One won't even recognize file directories, while the other will.  So, to keep things simple, I'm sticking to the one that does.  At any rate, don't want to turn this into a Windows gripe session.....

The code for the first test is included below.  I decided against the bump map preview that I previously discussed because there would need to be some extra coding I didn't account for in my response.  It's not too difficult, but it really makes the script unnecessarily cluttered. 

Here's my suggestion as how to work around the preview issue:  The basic concept for the script uses a pre-made pattern called "Watermark".  You can use any other pattern, but the script looks for the "Watermark" as the default.  So, create and save a "Watermark" pattern (needs to be spelled exactly as I have shown, without the quote marks).  I can change all defaults later, but this is how the test works.  For a preview, on a test image, add a new, transparent layer above the image (make the transparent layer the same size as your pattern) and fill the transparent layer with the pattern.  Then, make your image layer active and manually run the bump map filter to see what looks good to you.  Write down your settings and then run the script and substitute the defaults with your settings.  I know this is not as convenient, but it works.  Also, if you find that you're using certain bump map settings more than the defaults, I can modify the script so that your settings become the defaults.

This test will let you specify the folder to load the pictures from, identify the watermark pattern to be used (again, it can be any pattern, but for the time being, you need a default "Watermark" pattern), the location of the pattern (upper left/right, center, lower left/right), its color/opacity, bump map settings, where to save the pictures to and the new name of the pictures.  I've tested it on various image sizes and it appears to work.  I will let you know that the default settings don't look that great because the default opacity of 100 kinda hides the watermark.  But, again, everything is pretty much open for modification.  Once we know this works, adding the hidden watermark will be a piece of cake.

Lastly, should the script always perform the bump map/hidden watermark steps or should there be the option to choose?  I can code that in with no problem.....just a thought.

Copy/paste the code into a new text document and save it to your GIMP scripts folder with an ".scm" extension.  Refresh your scripts and, for the time being, the script is found under File > Watermark... (if you have other suggestions where this should be placed in the menus, please advise).  Because I've removed the option for the preview, you no longer need an open image to run the script.

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

(let* (

(filelist (cadr (file-glob (string-append load "\\*" ".jpg") 1)))
(s 1)
(count (car (file-glob (string-append load "\\*" ".jpg") 1)))
(drawable 0)
(patWidth (car (gimp-pattern-get-info pattern)))
(patHeight (cadr (gimp-pattern-get-info pattern)))
(patLayer 0)
(active 0)
(bumpLayer 0)
(filename2 0)
(offsetX 0)
(offsetY 0)
(imageWidth 0)
(imageHeight 0)


)





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

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


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

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


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

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

)

(set! patLayer (car (gimp-layer-new image patWidth patHeight RGBA-IMAGE "Pattern Layer" opacity NORMAL-MODE)))
(set! bumpLayer (car (gimp-image-get-active-layer image)))
(gimp-drawable-fill patLayer TRANSPARENT-FILL)
(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-displays-flush)
(gimp-layer-resize-to-image-size patLayer)
(plug-in-bump-map RUN-NONINTERACTIVE image bumpLayer patLayer azimuth elevation depth 0 0 waterlevel ambient compensate invert type)
(set! active (car (gimp-image-flatten image)))
(gimp-displays-flush)
(set! filename2 (string-append location "/" filename (string-append (number->string s))".jpg"))
(gimp-file-save RUN-NONINTERACTIVE image active filename2 filename2)
(set! s (+ s 1))
;(gimp-image-delete (car newimage))
(set! count (- count 1))
(set! filelist (cdr filelist))
))
)
)
(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-PATTERN    "Pattern to use as bump map watermark" "Watermark"
SF-OPTION     "Watermark position" '("Upper Left" "Upper Right" "Center" "Lower Left" "Lower Right")
SF-COLOR      "Watermark color" '(255 255 255)
SF-ADJUSTMENT "Watermark opacity" '(100.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" '(0 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-DIRNAME    "Save pictures to" "Save To"
    SF-STRING     "Name for watermarked images" "filename"

)
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.


Tags:
 

anything