Face Analyze, Analyze group

This commit is contained in:
Daniel Odendahl Jr
2018-03-08 22:49:19 +00:00
parent 35f4bd0bbe
commit 10e9fc0c02
18 changed files with 88 additions and 21 deletions
+3 -1
View File
@@ -34,7 +34,9 @@ module.exports = class ContrastCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
contrast(ctx, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'contrast.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'contrast.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -40,7 +40,9 @@ module.exports = class DistortCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
distort(ctx, level, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'distort.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'distort.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -34,7 +34,9 @@ module.exports = class GlitchCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
distort(ctx, 20, 0, 0, data.width, data.height, 5);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'glitch.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'glitch.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -35,7 +35,9 @@ module.exports = class GreyscaleCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
greyscale(ctx, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'greyscale.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -37,7 +37,9 @@ module.exports = class IfunnyCommand extends Command {
ctx.fillStyle = '#181619';
ctx.fillRect(0, canvas.height - base.height, canvas.width, base.height);
ctx.drawImage(base, canvas.width - base.width, canvas.height - base.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ifunny.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'ifunny.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -34,7 +34,9 @@ module.exports = class InvertCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
invert(ctx, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'invert.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -34,7 +34,9 @@ module.exports = class SepiaCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
sepia(ctx, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sepia.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'sepia.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -34,7 +34,9 @@ module.exports = class SilhouetteCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(data, 0, 0);
silhouette(ctx, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'silhouette.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'silhouette.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -1
View File
@@ -39,7 +39,9 @@ module.exports = class TintCommand extends Command {
const canvas = createCanvas(data.width, data.height);
const ctx = canvas.getContext('2d');
drawImageWithTint(ctx, data, color, 0, 0, data.width, data.height);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'tint.png' }] });
const attachment = canvas.toBuffer();
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
return msg.say({ files: [{ attachment, name: 'tint.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}