Removed format argument from jpeg, modified bufferPromise function a bit
This commit is contained in:
parent
d1792d8885
commit
b7aeacdf66
2 changed files with 37 additions and 15 deletions
|
@ -49,22 +49,44 @@ module.exports = async () => {
|
|||
//gm.prototype.bufferPromise = promisify(gm.prototype.toBuffer);
|
||||
gm.prototype.bufferPromise = function(format, type) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.out(type !== "sonic" ? "-layers" : "", type !== "sonic" ? "optimize" : "").stream(format, (err, stdout, stderr) => {
|
||||
if (err) return reject(err);
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
if (format) {
|
||||
console.log(format);
|
||||
this.out(type !== "sonic" ? "-layers" : "", type !== "sonic" ? "optimize" : "").stream(format, (err, stdout, stderr) => {
|
||||
if (err) return reject(err);
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
console.log(chunk);
|
||||
chunks.push(chunk);
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
console.log(Buffer.concat(chunks));
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
reject(data.toString());
|
||||
});
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
} else {
|
||||
this.out(type !== "sonic" ? "-layers" : "", type !== "sonic" ? "optimize" : "").stream((err, stdout, stderr) => {
|
||||
if (err) return reject(err);
|
||||
const chunks = [];
|
||||
stdout.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
// these are 'once' because they can and do fire multiple times for multiple errors,
|
||||
// but this is a promise so you'll have to deal with them one at a time
|
||||
stdout.once("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
reject(data.toString());
|
||||
});
|
||||
});
|
||||
stderr.once("data", (data) => {
|
||||
reject(data.toString());
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// tweet stuff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue