diff --git a/package.json b/package.json index 65190ac..1d3b406 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,7 @@ "node-html-markdown": "~1.3.0", "node-html-parser": "~6.1.5", "gpt-3-encoder": "~1.1.4", - "user-agents": "~1.0.1303", - "canvas": "~2.11.0" + "user-agents": "~1.0.1303" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", diff --git a/utilities/mergeImages.js b/utilities/mergeImages.js deleted file mode 100644 index d4b3e20..0000000 --- a/utilities/mergeImages.js +++ /dev/null @@ -1,70 +0,0 @@ -const { createCanvas, loadImage } = require("canvas"); -const fs = require("fs"); - -/** - * - * @param {Array} images The array of images to be merged together - * @param {function} callback The callback function to call with the merged images - * @returns {*} A PNG encoded image - */ -exports.mergeImages = async (images, callback) => { - if (!images) return callback(new Error("No images provided to merge"), undefined); - const numberOfImages = images.length; - const finalImageWidth = 1024; - const finalImageHeight = 1024; - - switch(numberOfImages) { - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - default: - break; - } - - - const imagePosition = { - w: 400, - h: 88, - x: 400, - // Calculate the Y of the image based on the number of - // lines in the title. - y: titleText.length === 2 ? 75 : 100, - }; - - -} - -// Do the same with the title's Y value. -const titleY = titleText.length === 2 ? 300 : 350; -const titleLineHeight = 100; -// And the author's Y value. -const authorY = titleText.length === 2 ? 525 : 500; - -const canvas = createCanvas(width, height); -const context = canvas.getContext("2d"); - -context.fillStyle = "#764abc"; -context.fillRect(0, 0, width, height); - -context.font = "bold 70pt 'PT Sans'"; -context.textAlign = "center"; -context.fillStyle = "#fff"; - -context.fillText(titleText[0], 600, titleY); -if (titleText[1]) context.fillText(titleText[1], 600, titleY + titleLineHeight); - -context.font = "40pt 'PT Sans'"; -context.fillText(`by ${post.author}`, 600, authorY); - -await loadImage("./assets/logo.png").then((image) => { - const { w, h, x, y } = imagePosition; - context.drawImage(image, x, y, w, h); -}); - -const buffer = canvas.toBuffer("image/png"); -fs.writeFileSync("./image.png", buffer); \ No newline at end of file