Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jcblw/image-to-blob
Simple utility to convert img urls to blobs
https://github.com/jcblw/image-to-blob
Last synced: 24 days ago
JSON representation
Simple utility to convert img urls to blobs
- Host: GitHub
- URL: https://github.com/jcblw/image-to-blob
- Owner: jcblw
- Created: 2014-12-19T07:52:46.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-08-10T13:20:29.000Z (over 5 years ago)
- Last Synced: 2024-10-11T14:39:13.516Z (about 1 month ago)
- Language: JavaScript
- Size: 2.61 MB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Image to Blob [![Build Status](https://travis-ci.org/jcblw/image-to-blob.svg?branch=master)](https://travis-ci.org/jcblw/image-to-blob)
[![Greenkeeper badge](https://badges.greenkeeper.io/jcblw/image-to-blob.svg)](https://greenkeeper.io/)
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](http://browserify.org).
## Install
$ npm install image-to-blob
## Example Usage
```javascript
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.