overleaf/services/filestore/app/coffee/ImageOptimiser.coffee
Henry Oswald b38e7d3078 * delete both file and converted file if there is an error
* increase timeout of optpng
2016-12-13 12:43:57 +00:00

20 lines
556 B
CoffeeScript

exec = require('child_process').exec
logger = require("logger-sharelatex")
module.exports =
compressPng: (localPath, callback)->
startTime = new Date()
logger.log localPath:localPath, "optimising png path"
args = "optipng #{localPath}"
opts =
timeout: 30 * 1000
killSignal: "SIGKILL"
exec args, opts,(err, stdout, stderr)->
if err?
logger.err err:err, stderr:stderr, localPath:localPath, "something went wrong converting compressPng"
else
logger.log localPath:localPath, "finished compressPng file"
callback(err)