Detect if an image or canvas has any transparent pixels.

npm install opaque
3 downloads in the last day
14 downloads in the last week
70 downloads in the last month


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


Using NPM and Browserify:

npm install opaque

As a component:

component install hughsk/opaque



Returns false if transparent, or true if not.


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.

npm loves you