From 8066eb4c0491801ebdc5ca0655bbc569a167d0a8 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 28 Apr 2024 15:36:27 -0400 Subject: [PATCH] Fix --- commands/edit-image-text/tweet.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/edit-image-text/tweet.js b/commands/edit-image-text/tweet.js index 6a448847..a552ebed 100644 --- a/commands/edit-image-text/tweet.js +++ b/commands/edit-image-text/tweet.js @@ -80,19 +80,19 @@ module.exports = class TweetCommand extends Command { if (image) { const { body } = await request.get(image); const imageData = await loadImage(body); - const imageHeightRatio = 740 / imageData.width; + const imageWidth = 740; + const imageHeightRatio = imageWidth / imageData.width; imageHeight = imageData.height * imageHeightRatio; - const imageCanvas = createCanvas(740, imageHeight); + const imageCanvas = createCanvas(imageWidth, imageHeight); const imageCtx = imageCanvas.getContext('2d'); canvas.height += imageHeight + 30; ctx.fillRect(0, base1.height, canvas.width, linesLen + imageHeight + 30); const x = 0; const y = 0; - const imageWidth = 740; const radius = 15; this.roundedPath(imageCtx, radius, x, y, imageWidth, imageHeight); imageCtx.clip(); - imageCtx.drawImage(imageData, 0, 0, imageWidth, imageHeight); + imageCtx.drawImage(imageData, x, y, imageWidth, imageHeight); this.roundedPath(imageCtx, radius, x, y, imageWidth, imageHeight); imageCtx.strokeStyle = '#303336'; imageCtx.lineWidth = 5;