mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 15:57:47 +02:00
Double export jpeg in deepfry
This commit is contained in:
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { createCanvas, loadImage } = require('canvas');
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { desaturate, contrast } = require('../../util/Canvas');
|
const { desaturate, contrast } = require('../../util/Canvas');
|
||||||
|
const { load } = require('cheerio');
|
||||||
|
|
||||||
module.exports = class DeepFryCommand extends Command {
|
module.exports = class DeepFryCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -35,6 +36,10 @@ module.exports = class DeepFryCommand extends Command {
|
|||||||
ctx.drawImage(data, 0, 0);
|
ctx.drawImage(data, 0, 0);
|
||||||
desaturate(ctx, -20, 0, 0, data.width, data.height);
|
desaturate(ctx, -20, 0, 0, data.width, data.height);
|
||||||
contrast(ctx, 0, 0, data.width, data.height);
|
contrast(ctx, 0, 0, data.width, data.height);
|
||||||
|
const firstExport = canvas.toBuffer('image/jpeg', { quality: 0.3 });
|
||||||
|
if (Buffer.byteLength(firstExport) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
|
const firstExportImg = await loadImage(firstExport);
|
||||||
|
ctx.drawImage(firstExportImg, 0, 0);
|
||||||
const attachment = canvas.toBuffer('image/jpeg', { quality: 0.3 });
|
const attachment = canvas.toBuffer('image/jpeg', { quality: 0.3 });
|
||||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||||
return msg.say({ files: [{ attachment, name: 'deep-fry.jpeg' }] });
|
return msg.say({ files: [{ attachment, name: 'deep-fry.jpeg' }] });
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "116.27.3",
|
"version": "116.27.4",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user