Watermarks?


#1

I have desperately searched the web about how to apply watermarks to
images in RoR

Has anyone been able to apply watermarks to pictures using ruby?

Any tips are very much welcomed,

Thanks,

Roland


#2

Haven’t tried it myself, but you might try the “stegano” effect with
rmagic:

Here’s a link:
http://redux.imagemagick.org/RMagick/doc/image3.html#stegano

Dave

David Andrew T.
http://dathompson.blogspot.com

#3

Thank you David,

It seems that’s the way to go.

Roland


#4

I think I figured it out here is the code for anyone that is interested.

The suggestion of David, stegano, allows for some secret marking of the
images that can not be seen when looking at the image throug a viewer
such gthumb.

A better way is to simply replace the pixels as shown below.

require ‘RMagick’

watermark = Magick::Image.read(‘watermark.gif’).first
wr = watermark.rows
wc = watermark.columns

img = Magick::Image.read(‘original.gif’).first
ir = img.rows
ic = img.columns

img.store_pixels(ir-wr, 0, wr, wc ,watermark.get_pixels(0,0, wr, wc))
img.write(‘fina.gif’)