node-image-watermark
v0.1.3
Published
Simple solution for watermarking images with other images.
Downloads
6
Readme
node-image-watermark
Using the moodule
- Install GraphicsMagick on your machine (or a buildpack on your server)
- Install the NPM module
npm i node-image-watermark
- Import the module
const watermark = require("node-image-watermark")
- 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