node-image-watermark

0.1.3 • Public • Published

node-image-watermark

npm version Issues Forks Stars License: GPL v2

See the demo (view source)

Using the moodule

  1. Install GraphicsMagick on your machine (or a buildpack on your server)
  2. Install the NPM module
    npm i node-image-watermark
  3. Import the module
const watermark = require("node-image-watermark")
  1. Set your params according to your requirements:
app.get("/img/:imageUrl", (req, res) => {
  const { imageUrl } = req.params
  if (!imageUrl) res.sendStatus(404)

  res.set("Content-Type", "image/png")
  watermark({
    geometry: "45,45",
    resize: "1600,900",
    watermarkPath: "./watermark.png",
  }).pipe(res)
})



Params:

Pass geometry, resize, and watermarkPath as options properties in order to customize the image.

  • resize: String representation of a tuple of X, Y dimensions for resizing the base image (ex: "800,450")

  • geometry: String representation of a tuple of X, Y coordinates for where to place the watermark (ex: "30,30")

  • watermarkPath: Local path to a watermark image file (ex: ./watermark.png)




resources:

Heroku Buildpack: https://elements.heroku.com/buildpacks/xerpa/heroku-buildpack-graphicsmagick

Readme

Keywords

none

Package Sidebar

Install

npm i node-image-watermark

Weekly Downloads

0

Version

0.1.3

License

GPL-2.0

Unpacked Size

28.4 kB

Total Files

7

Last publish

Collaborators

  • retzion