const child_process = require('child_process'); exports.dothumb = async function (path) { const child = child_process.exec(`convert -quiet $(ls | head -n 1)[0] -resize 320x320^ -gravity Center -crop 320x320+0+0 thumb.jpg`, { cwd: `${path}` }); return new Promise((resolve, reject) => { child.addListener("error", reject); child.addListener("exit", resolve); }); }