UNPKG

discord-image-utils

Version:

A powerful library for generating and modifying images with Discord.js - includes meme generation, filters, effects and animations

31 lines 1.25 kB
"use strict"; /** @format */ Object.defineProperty(exports, "__esModule", { value: true }); const jimp_1 = require("jimp"); const utils_1 = require("./utils"); class Mirror { /** * Mirrors an image horizontally (or vertically) * @param image - The image URL or buffer to process * @param horizontal - Whether to flip horizontally (default: true) * @param vertical - Whether to flip vertically (default: false) * @returns A promise that resolves to a Buffer containing the processed image. */ async getImage(image, horizontal = true, vertical = false) { if (!image) { throw new Error("You must provide an image as the first argument."); } const isValid = await (0, utils_1.validateURL)(image); if (!isValid) { throw new Error("You must provide a valid image URL or buffer."); } // Use Jimp's read function to load the image. const jimpImage = await jimp_1.Jimp.read(image); // Flip the image horizontally and/or vertically. jimpImage.flip({ horizontal, vertical }); const buffer = await jimpImage.getBuffer("image/png"); return buffer; } } exports.default = Mirror; //# sourceMappingURL=mirror.js.map