npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vantezzen/watermark

v1.0.0

Published

Add hidden watermarks to uncompressed images (PNG, BMP etc.) that do not rely on image metadata by tweaking RGB values.

Downloads

1

Readme

@vantezzen/watermark - Add hidden watermarks to images

npm version

This package allows adding hidden watermarks to uncompressed images (PNG, BMP etc.) that do not rely on image metadata and are not visible to the eye. The watermark is added by tweaking the RGB values of the image slightly and it is still readable after cropping the image.

Possible use cases for the watermark are DRM or leak protection, adding a way to trace back the origins of an image or adding hidden copyright information.

What does it look like

| Original image | Watermarked image | | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | | Original image | Watermarked image |

Features

  • [x] Add arbitrary strings up to a specific length to an image
  • [x] Doesn't rely on image metadata as these are often removed by websites and services
  • [x] Watermark is still extractable if the image is cropped

Currently not supported

With its current limitation, the watermark cannot be read if the pixel data of the image have been altered - though some limitations can be removed by improving the code.

Some limitations include:

  • Compression (e.g. JPG) makes the watermark unreadable
  • Stretching, rotating or zooming the image makes the watermark unreadable
  • Image editing (e.g. brightness) makes the watermark unreadable

Installation

npm install @vantezzen/watermark

Usage

Interaction with the package is done through the Watermark class. It can be used to add watermarks to images and to extract watermarks from images.

An example of how to use the package can be found in the example folder.

Adding a watermark

import Watermark from '@vantezzen/watermark';
import fs from 'fs';

// You need to load your image as a Buffer, e.g. using fs.readFile
const image = fs.readFileSync(join(__dirname, 'test.png'));

// Create a new Watermark instance
const watermark = new Watermark(image);

// Add a watermark to the image
// This will modify the image stored inside the Watermark instance
await watermark.addWatermark('Hello World!');

// Get the modified image as a Buffer
const modifiedImage = await watermark.getImage();

// You can save the modified image to disk, e.g. using fs.writeFile
fs.writeFileSync(join(__dirname, 'test-watermarked.png'), modifiedImage);

Extracting a watermark

Note: The Watermark instance saves image pixel data and metadata internally. Create separate instances for separate images instead of reusing the same one.

import Watermark from '@vantezzen/watermark';
import fs from 'fs';

// You need to load your watermarked image as a Buffer, e.g. using fs.readFile
const image = fs.readFileSync(join(__dirname, 'test-watermarked.png'));

// Create a new Watermark instance
const watermark = new Watermark(image);

// Extract the watermark from the image
const extractedWatermark = await watermark.extractWatermark();

// The extracted watermark will be null if no watermark was found
console.log(extractedWatermark); // Hello World!

License

MIT