deasync
deasync copied to clipboard
combination lwip imageprocessing / deasync fails
Im trying to batch scale / process photos and do other manipulations on many images (and other files) in a dir tree. No need to do asynchronously and deasync would make resulting code more readable (at least for me). The Lwip library looked nice as it has no dependencies.
but the code below fails:
node_modules/lwip/lib/ImagePrototypeInit.js:97 this.__lock(); ^ TypeError: undefined is not a function at Image.scale (node_modules/lwip/lib/ImagePrototypeInit.js:97:14) at node_modules/deasync/index.js:35:6 at Object.
(deasynctest.js:18:29)
maybe because lwip uses async? Simple code (requires a photo.jpg file)
var lwip = require('lwip');
// normal lwip interface, working fine
lwip.open('photo.jpg', function (err, image) {
image.scale(0.5, function (err, image) {
image.writeFile('photoasync.jpg', function (err) {
})
})
});
// using deasync
var deasync = require('deasync');
var image = deasync(lwip.open)('photo.jpg'); // works (nice!)
console.log('opened');
image = deasync(image.scale)(0.5); // fails
console.log('scaled');
deasync(image.writeFile)('photosync.jpg'); // fails (even without scaling)
console.log('written');
using deasync 0.1.4 and lwip 0.0.8