Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including opaque with all npm packages installed. Try it out:

var opaque = require("opaque")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

opaque v0.0.1

Detect if an image or canvas has any transparent pixels.


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.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free