tingle-bot/src/modules/images/overlayImages.ts
Naomi Carrigan 7c0bd7ad10 feat: update this highly outdated app to use latest packages and custom configs (#1)
Reviewed-on: https://codeberg.org/nhcarrigan/tingle-bot/pulls/1
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2024-09-26 19:46:33 +00:00

29 lines
842 B
TypeScript

/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { join } from "node:path";
import sharp from "sharp";
import type { AttachmentData }
from "../../interfaces/commands/attachmentData.js";
/**
* Module to combine an overlay and a banner.
* @param banner - The file path for the banner.
* @param overlay - The file path for the overlay.
* @returns The attachment data for the new banner.
*/
export const overlayImages = async(
banner: string,
overlay: string,
): Promise<AttachmentData> => {
await sharp(banner).
composite([ { gravity: "center", input: overlay } ]).
toFile(join(process.cwd(), "src", "assets", "overlay.png"));
return {
attachmentString: `attachment://overlay.png`,
filePath: join(process.cwd(), "src", "assets", "overlay.png"),
};
};