thedesk/app/node_modules/jimp/browser/examples/jimp-worker.js
2019-09-12 23:38:13 +09:00

19 lines
427 B
JavaScript

/* 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();
});
});
});