0.1.13 • Published 3 years ago

image-worker v0.1.13

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

image-worker

description

Quickly get the dimensions and base64 url of an image file without blocking the UI (additional features coming later).

installation

recommended

npm install --save-dev image-worker

old school

<script type="text/javascript" src="dist/image-processor-worker.js"></script>
var processor = new ImageProcessor(file);

usage

tl/dr

var IP = require('image-processor-worker');
var ip = new IP(file) //javascript File object;
ip.getDetails({preview: true}).then(function(details){
    console.log(details);
})

will yield the following JSON object

{
    width: 100,
    height: 100,
    preview: 'data:image/jpeg;base64,/dg06HthpF...'
}

longer example

Assuming you have the following HTML

<input id="file" type="file" />

and javascript:

var ImageProcessor = require('image-processor-worker');
var field = document.getElementById('file');
field.addEventListener('change', function(e){
    var file = e.target.files[0];
    var processor = new ImageProcessor(file);
    processor.getDetails().then(function(result){
        console.log(result);
    });
})

you'll get the following output:

{
    width: 100,
    height: 100,
    preview: 'data:image/jpeg;base64,/dg06HthpF...'
}
0.1.13

3 years ago

0.1.11

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago