2014-02-19 13:02:53 +00:00
|
|
|
exec = require('child_process').exec
|
2014-02-14 16:39:05 +00:00
|
|
|
logger = require("logger-sharelatex")
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
compressPng: (localPath, callback)->
|
|
|
|
startTime = new Date()
|
2014-02-19 13:02:53 +00:00
|
|
|
logger.log localPath:localPath, "optimising png path"
|
|
|
|
args = "optipng #{localPath}"
|
|
|
|
opts =
|
2014-02-20 11:45:51 +00:00
|
|
|
timeout: 20 * 1000
|
2014-03-04 12:44:16 +00:00
|
|
|
killSignal: "SIGKILL"
|
2014-02-19 14:01:53 +00:00
|
|
|
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"
|
2014-03-04 12:44:16 +00:00
|
|
|
callback(err)
|
2014-02-19 13:02:53 +00:00
|
|
|
|
2014-02-14 16:39:05 +00:00
|
|
|
|