Skip to content
/ opaque Public

Detect whether an image or canvas element contains any transparent pixels.

License

Notifications You must be signed in to change notification settings

hughsk/opaque

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opaque

Browserify module for detecting if an image or canvas element has transparent pixels.

Installation

Using NPM and Browserify:

npm install opaque

As a component:

component install hughsk/opaque

Usage

opaque(element)

Returns false if transparent, or true if not.

opaque.transparent(element)

The opposite of opaque: true if transparent, false if not.

var opaque = require('opaque')
  , transparent = require('opaque').transparent

var brick = new Image
brick.src = '/brick.png'
brick.onload = function() {
  opaque(brick)      // true
  transparent(brick) // false
};

var glass = new Image
glass.src = '/glass.png'
glass.onload = function() {
  opaque(glass)      // false
  transparent(glass) // true
};

Note that an image must be fully loaded before being checked.

About

Detect whether an image or canvas element contains any transparent pixels.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published