You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 30, 2024. It is now read-only.
I have a function in nodejs, some reason i want it synchonize before do another step. I research a lot but no solution working. Currently i use node-sync:
My function like this:
function downloadImageIcon(url,path,ori,callback){
var request = require('request');
//Sync(function() {
request.get({url: url, encoding: 'binary'}, function (err, response, body) {
console.log("start load: " + path);
//Sync(function() {
fs.writeFile( ori, body, 'binary', function (err) {
if (err)
console.log(err);
else {// if success then we need to convert it
console.log("converting : " + path);
fs.writeFileSync( path, imagemagick.convert({
srcData: fs.readFileSync(ori),
width: 1024,
height: 1024,
resizeStyle: 'aspectfill', // is the default, or 'aspectfit' or 'fill'
gravity: 'Center' // optional: position crop area when using 'aspectfill'
}));
callback();
}
//});
});
console.log("end load: " + path);
});
//})
}
- download image from server
- store in local
- convert to different resolution
Function work well but i need it to synchronize when called. Thanks for investigate!
I have a function in nodejs, some reason i want it synchonize before do another step. I research a lot but no solution working. Currently i use node-sync:
My function like this:
Function work well but i need it to synchronize when called. Thanks for investigate!