image-to-blob

0.2.0 • Public • Published

Image to Blob Build Status

Image to Blob is a simple utility that will convert images to blobs this can be used for urls to images, that are not cross domain, and IMG DOM node. Its intended to be used with Browserify.

Install

$ npm install image-to-blob

Example Usage

var imageToBlob = require( 'image-to-blob' ),
    foo = document.getElementById( 'foo' ),
    DOMURL = window.URL || window.webkitURL || window;
 
function appendBlob( err, blob ) {
    if ( err ) {
        console.error( err );
        return;
    }
 
    console.log( blob );
    var img = document.createElement( 'img' );
    img.src = DOMURL.createObjectURL( blob );
    document.body.appendChild( img );    
}
 
imageToBlob( foo, appendBlob );
imageToBlob( './bar.svg', appendBlob );

This will convert SVG images to pngs.

/image-to-blob/

    Package Sidebar

    Install

    npm i image-to-blob

    Weekly Downloads

    60

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • ~jcblw