gm icon indicating copy to clipboard operation
gm copied to clipboard

How can i specify the watermark image?

Open ptgamr opened this issue 10 years ago • 7 comments

Hi there,

Documentation say: gm("img.png").watermark(brightness, saturation)

I wonder how to specify which image should be added as watermark?

Thanks for any help!

ptgamr avatar Apr 28 '14 17:04 ptgamr

As you can see in GraphicsMagic documentation (http://www.graphicsmagick.org/composite.html) -watermark is just option for powerful composite utility.

I recommend to google with keywords "GraphicsMagic" or "Imagemagick" and to try command line first of all:

gm composite -watermark 50x50 image.jpg watermark.png output.jpg

After that using gm is more simple ;-)

desigens avatar May 12 '14 19:05 desigens

Can you provide an example... its not that easy to understand the relation between GraphicsMagic and gm and there is no single example about composite and gm.

dimitarkolev avatar May 29 '14 15:05 dimitarkolev

@ptgamr @dimitarkolev I'm not sure if this is till an issue for you guys, but I create watermarked images with this pattern:

gm(source)
  .command('composite')
  .gravity('SouthEast')
  .out('-geometry', '+20+10') // offset
  .in('watermark.png')
  .stream()
  .pipe(dest);

madbence avatar Jun 08 '15 11:06 madbence

10x I'll try this. On Jun 8, 2015 14:19, "Bence Dányi" [email protected] wrote:

@ptgamr https://github.com/ptgamr @dimitarkolev https://github.com/dimitarkolev I'm not sure if this is till an issue for you guys, but I create watermarked images with this pattern:

gm(source) .command('composite') .gravity('SouthEast') .out('-geometry', '+20+10') // offset .in('watermark.png') .stream() .pipe(dest);

— Reply to this email directly or view it on GitHub https://github.com/aheckmann/gm/issues/276#issuecomment-109955651.

dimitarkolev avatar Jun 08 '15 12:06 dimitarkolev

@madbence Thank you it worked! I was trying following way, but didn't know how to specify watermark location.

gm(readStream)
.autoOrient()
.resize(1280, 1024)
.gravity('SouthEast')
.draw('image Over 10,10 0,0 ' + getAppPath() + '/public/img/watermark.png')
.stream('PNG')
.pipe(writeStream);

digz6666 avatar Aug 13 '15 03:08 digz6666

Hi

Is it possible to specify a buffer (e.g. from a file upload) for the watermark instead of the physical file on a server?

Thanks Damien

damogallagher avatar Oct 29 '18 15:10 damogallagher

gm('./background.jpg')
  .autoOrient()
  .resize(1000, 1000)
  .draw("image Over 100,300 0,0 './logo.png'")
  .write('./img/backgroundwithlogo.png', function(err) {
    if (!err) console.log('done');
  });

this code is worked for me. 100,300 is watermark location. @digz6666

Security111588 avatar Mar 05 '19 07:03 Security111588