Skip to content

Watermarking

Janko Marohnić edited this page Jul 13, 2018 · 5 revisions

A watermark can be applied to an image during processing.

MiniMagick

From the composite documentation:

Take the first image 'destination' and overlay the second 'source' image according to the current -compose setting. The location of the 'source' or 'overlay' image is controlled according to -gravity, and -geometry settings.

ImageProcessing::MiniMagick provides a #composite wrapper method for defining composition:

watermark # can be String, Pathname, File, or Tempfile

ImageProcessing::MiniMagick
  .source(original)
  .composite(watermark,    # Set the watermark as the overlay image
    mode: "over",          # Apply the watermark 'over' the source (default)
    gravity: "south-east", # Apply the watermark in the bottom right corner
    offset: [10, 10],      # Apply the watermark 10 pixels up and left from ':gravity' setting
  )
  .call                    # Apply operation

Vips

ImageProcessing::Vips provides a #composite wrapper method around the vips_composite() libvips function:

watermark # can be String, Pathname, File, Tempfile, or Vips::Image

ImageProcessing::Vips
  .source(original)
  .composite(watermark,    # Set the watermark as the overlay image
    mode: "over",          # Apply the watermark 'over' the source (default)
    gravity: "south-east", # Apply the watermark in the bottom right corner
    offset: [10, 10],      # Apply the watermark 10 pixels up and left from ':gravity' setting
  )
  .call                    # Apply operation
You can’t perform that action at this time.