thedesk/app/node_modules/jimp/browser/examples/jimp-worker.js

19 lines
427 B
JavaScript
Raw Normal View History

2019-09-13 00:38:13 +10:00
/* eslint-env worker */
/* global Jimp */
importScripts('../lib/jimp.min.js');
self.addEventListener('message', e => {
Jimp.read(e.data).then(lenna => {
lenna
.resize(256, Jimp.AUTO) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.getBase64(Jimp.AUTO, (err, src) => {
if (err) throw err;
self.postMessage(src);
self.close();
});
});
});