All Projects → brianium → Watermarkjs

brianium / Watermarkjs

Licence: other
🎑 Watermarking for the browser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Watermarkjs

Fantasy Land
Specification for interoperability of common algebraic structures in JavaScript
Stars: ✭ 9,209 (+476.64%)
Mutual labels:  functional
Gemma
A lightweight CSS library.
Stars: ✭ 94 (-94.11%)
Mutual labels:  functional
Tiny Atom
Pragmatic and concise state management.
Stars: ✭ 109 (-93.17%)
Mutual labels:  functional
Nano Style
React functional CSS-in-JS
Stars: ✭ 85 (-94.68%)
Mutual labels:  functional
Fuego
Functional Experiment in Golang
Stars: ✭ 87 (-94.55%)
Mutual labels:  functional
Cron4s
Cross-platform CRON expression parsing for Scala
Stars: ✭ 99 (-93.8%)
Mutual labels:  functional
Oh
A new Unix shell.
Stars: ✭ 1,206 (-24.48%)
Mutual labels:  functional
Effector React Realworld Example App
Exemplary real world application built with Effector + React
Stars: ✭ 119 (-92.55%)
Mutual labels:  functional
Dush
👏 Microscopic & functional event emitter in ~350 bytes, extensible through plugins.
Stars: ✭ 87 (-94.55%)
Mutual labels:  functional
Motorcyclejs
A statically-typed, functional and reactive framework for modern browsers
Stars: ✭ 107 (-93.3%)
Mutual labels:  functional
Html
A Virtual DOM based templating-engine for PHP
Stars: ✭ 86 (-94.61%)
Mutual labels:  functional
Funcy.js
funcy.js - a functional web components wrapper
Stars: ✭ 87 (-94.55%)
Mutual labels:  functional
Lens
A utility for working with nested data structures.
Stars: ✭ 104 (-93.49%)
Mutual labels:  functional
Bulb
A reactive programming library for JavaScript.
Stars: ✭ 84 (-94.74%)
Mutual labels:  functional
Alembic
⚗️ Functional JSON Parser - Linux Ready 🐧
Stars: ✭ 115 (-92.8%)
Mutual labels:  functional
Fantas Eel And Specification
Examples and exercises from the blog series
Stars: ✭ 77 (-95.18%)
Mutual labels:  functional
Rxstorekit
StoreKit library for RxSwift
Stars: ✭ 96 (-93.99%)
Mutual labels:  functional
Atto
An insanely simple self-hosted functional programming language
Stars: ✭ 119 (-92.55%)
Mutual labels:  functional
Pyrsistent
Persistent/Immutable/Functional data structures for Python
Stars: ✭ 1,621 (+1.5%)
Mutual labels:  functional
Forge
Functional style JSON parsing in Kotlin
Stars: ✭ 106 (-93.36%)
Mutual labels:  functional

watermark.js Build Status

A functional library for watermarking images in the browser. Written with ES6, and made available to current browsers via Babel. Supports urls, file inputs, blobs, and on-page images.

Note: For anyone that is interested: I ported this to a ClojureScript library called Dandy Roll.

Tested Browsers

Any browser supporting File and FileReader should work. The following browsers have been tested and work:

  • IE10 (Windows 7)
  • Chrome 42 (OS X 10.10.3)
  • Firefox 38 (OS X 10.10.3)
  • Safari 8.0.6 (OS X 10.10.3)
  • Opera 29.0 (OS X 10.10.3)

Please feel free to update this list or submit a fix for a particular browser via a pull request.

Installing

watermark.js is available via npm and bower:

# install via npm
$ npm install watermarkjs

# install via bower
$ bower install watermarkjs

Usage

// watermark by local path
watermark(['img/photo.jpg', 'img/logo.png'])
  .image(watermark.image.lowerRight(0.5))
  .then(img => document.getElementById('container').appendChild(img));

// load a url and file object
const upload = document.querySelector('input[type=file]').files[0];
watermark([upload, 'img/logo.png'])
  .image(watermark.image.lowerLeft(0.5))
  .then(img => document.getElementById('container').appendChild(img));

// watermark from remote source
const options = {
  init(img) {
    img.crossOrigin = 'anonymous'
  }
};
watermark(['http://host.com/photo.jpg', 'http://host.com/logo.png'], options)
  .image(watermark.image.lowerRight(0.5))
  .then(img => document.getElementById('container').appendChild(img));

Building

Before building or testing, install all the deps:

npm i

There is an npm script you can run to build:

npm run build

Or to kick off the file watcher and build as you make changes, run the start task:

$ npm start

Testing

There is an npm script for that too!:

$ npm test

This library uses the Jest testing framework. Due to some current issues with Jest, Node 0.10.x is required to run the tests.

Examples

You can view examples and documentation by running the sync task via npm:

$ npm run sync

The examples demonstrate using watermark images and text, as well as a demonstration of uploading a watermarked image to Amazon S3. It is the same content hosted at http://brianium.github.io/watermarkjs/.

Development

Running npm run dev will start a browser and start watching source files for changes.

Motivation

  • Not every server has image libraries (shared hosting anyone?)
  • Not every server has reliable concurrency libs for efficient uploading (shared hosting anyone?)
  • JavaScript is fun and cool - more so with ES6

Clearly watermarking on the client has some limitations when watermarking urls and on-page elements. The curious can find urls for non-watermarked images, but it is likely that most average users won't go down this path - keeping this soft barrier useful. However!...

watermark.js has the ability to accept file inputs as a source for watermarking. This makes it easy to preview, watermark, and upload without the non-watermarked image ever becoming public. Check out the uploading demo to see this in action.

This tool certainly shines in admin or CMS environments where you want to generate watermarks and upload them asynchronously where it would not be possible or preferable on the server. One less thing the server has to do can be a good thing :)

Suggestions? Improvements?

Please open issues or pull requests if you have bugs/improvements.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].