Resize images
Hello, I have been using manet, so far is works pretty good, I would like to know if it would be hard to implement image resizing, for example I would like to get thumbnails for desktop screenshots, I would like to implement this myself however I don't know exactly where should I place the code.
https://www.npmjs.com/package/resize
this seems like a good library for this.
function minimizeImage(src, dest, cb) {
squirrel(
IMIN_MODULES, IMIN_OPTIONS,
(err, Imagemin) => {
const safeCb = (err) => {
if (err) {
logger.error(err);
}
cb();
};
if (err) {
safeCb(err);
} else {
const imin = new Imagemin()
.src(src)
.dest(dest)
.use(Imagemin.jpegtran({progressive: true}))
.use(Imagemin.optipng({optimizationLevel: 3}))
.use(Imagemin.gifsicle({interlaced: true}))
.use(Imagemin.svgo());
imin.run(safeCb);
}
}
);
}
I am guessing I should make a function like this one ?
and then add it here
function runCapturingProcess(options, config, outputFile, base64, onFinish) {
const scriptFile = utils.filePath(SCRIPT_FILE),
command = cliCommand(config).split(/[ ]+/),
cmd = _.union(command, [scriptFile, base64, outputFile]),
opts = {
timeout: config.timeout
};
logger.debug(
'Options for script: %s, base64: %s, command: %s',
JSON.stringify(options), base64, JSON.stringify(cmd)
);
utils.execProcess(cmd, opts, (error) => {
if (config.compress) {
minimizeImage(outputFile, config.storage, () => onFinish(error));
//resize here ?
} else {
onFinish(error);
}
});
}
We could use this as well. @vbauer do you think @xkidro is on the right track here?
@xkidro @GuiSim Yes, I think it should be something here (btw, I'm opened for PR)
Any update on this?
Has anyone implemented resize screenshot functionality?
I am trying to install resize npm package into Manet but I am getting following error.
`> [email protected] install /usr/local/lib/node_modules/manet/node_modules/graphicsmagick2
node-gyp rebuild
gyp ERR! clean error
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/manet/node_modules/graphicsmagick2
gyp ERR! node -v v8.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! /Users/malayladu/.npm/_logs/2017-09-07T04_56_12_409Z-debug.log`
Any thought on this?
It was a permission related issue.. Fixed it.