You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, message = "Au revoir...", textColor = "#FFFFFF", fontSize = 80, position = "bottom") {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
// Match canvas dimensions to the original image
canvas.width = originalImg.width;
canvas.height = originalImg.height;
// Draw the original image onto the canvas
ctx.drawImage(originalImg, 0, 0);
// Sanitize and set number-based inputs
const fSize = Number(fontSize) || Math.max(40, Math.floor(canvas.height / 10));
// Determine Y coordinate and text baseline based on position
let x = canvas.width / 2;
let y;
position = String(position).toLowerCase();
// Apply a subtle black gradient/overlay to ensure text readability against any image background
if (position === "top") {
ctx.textBaseline = "top";
y = fSize / 2;
const grad = ctx.createLinearGradient(0, 0, 0, y + fSize * 1.5);
grad.addColorStop(0, "rgba(0,0,0,0.7)");
grad.addColorStop(1, "rgba(0,0,0,0)");
ctx.fillStyle = grad;
ctx.fillRect(0, 0, canvas.width, y + fSize * 2);
} else if (position === "center") {
ctx.textBaseline = "middle";
y = canvas.height / 2;
// Full subtle overlay for center text
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
} else {
// Default to "bottom"
ctx.textBaseline = "bottom";
y = canvas.height - (fSize / 2);
const grad = ctx.createLinearGradient(0, canvas.height, 0, canvas.height - fSize * 2.5);
grad.addColorStop(0, "rgba(0,0,0,0.7)");
grad.addColorStop(1, "rgba(0,0,0,0)");
ctx.fillStyle = grad;
ctx.fillRect(0, canvas.height - fSize * 2.5, canvas.width, fSize * 2.5);
}
// Configure text styling (elegant classic web-safe font)
ctx.font = `italic ${fSize}px "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif`;
ctx.textAlign = "center";
const maxWidth = canvas.width - (fSize); // Add some padding on the sides
// Draw outline/stroke for extra contrast
ctx.lineWidth = Math.max(2, fSize * 0.04);
ctx.strokeStyle = "rgba(0, 0, 0, 0.9)";
ctx.strokeText(message, x, y, maxWidth);
// Draw the main text with a drop shadow
ctx.fillStyle = String(textColor);
ctx.shadowColor = "rgba(0, 0, 0, 0.8)";
ctx.shadowBlur = 10;
ctx.shadowOffsetX = 3;
ctx.shadowOffsetY = 3;
ctx.fillText(message, x, y, maxWidth);
return canvas;
}
Apply Changes