You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, title = "Братец Том", author = "Г. Б. Стоу", theme = "vintage") {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// Keep original dimensions
canvas.width = originalImg.width;
canvas.height = originalImg.height;
// Apply thematic 19th-century atmospheric filters
if (theme === "vintage") {
ctx.filter = 'sepia(0.8) contrast(1.2) brightness(0.85) saturate(0.8)';
} else if (theme === "dark") {
ctx.filter = 'grayscale(0.5) contrast(1.3) brightness(0.7)';
} else {
ctx.filter = 'none';
}
// Draw the original image taking into account the filter
ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);
ctx.filter = 'none'; // reset filter for subsequent drawings
// Add vignette to center the focus and add age/decay feel
const grad = ctx.createRadialGradient(
canvas.width / 2, canvas.height / 2, Math.min(canvas.width, canvas.height) * 0.3,
canvas.width / 2, canvas.height / 2, Math.max(canvas.width, canvas.height) * 0.8
);
grad.addColorStop(0, 'rgba(0,0,0,0)');
grad.addColorStop(1, theme === 'vintage' ? 'rgba(50, 20, 5, 0.75)' : 'rgba(0,0,0,0.85)');
ctx.fillStyle = grad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Dynamic padding scaling based on image size
const padding = Math.min(canvas.width, canvas.height) * 0.06;
// Draw Classic Book Cover Borders
ctx.strokeStyle = theme === 'vintage' ? '#D4AF37' : '#E0E0E0'; // Gold or Silver
// Outer border
ctx.lineWidth = Math.max(2, padding * 0.15);
ctx.strokeRect(padding, padding, canvas.width - padding * 2, canvas.height - padding * 2);
// Inner delicate border
const innerPadding = padding + padding * 0.3;
ctx.lineWidth = Math.max(1, padding * 0.05);
ctx.strokeRect(innerPadding, innerPadding, canvas.width - innerPadding * 2, canvas.height - innerPadding * 2);
// Text Settings
ctx.textAlign = 'center';
ctx.fillStyle = theme === 'vintage' ? '#F9F1E6' : '#FFFFFF';
// Heavy Drop Shadow for Text to stand out against any background
ctx.shadowColor = 'rgba(0, 0, 0, 0.9)';
ctx.shadowBlur = Math.max(5, canvas.width * 0.01);
ctx.shadowOffsetX = Math.max(2, canvas.width * 0.005);
ctx.shadowOffsetY = Math.max(2, canvas.width * 0.005);
// Title text format (Top)
const titleSize = Math.max(16, canvas.width * 0.1);
ctx.font = `bold ${titleSize}px 'Georgia', serif`;
ctx.textBaseline = 'top';
// For multiline title if long
const titleYOffset = innerPadding + padding * 0.5;
ctx.fillText(title, canvas.width / 2, titleYOffset, canvas.width - (innerPadding * 2) - 20);
// Author text format (Bottom)
const authorSize = Math.max(12, canvas.width * 0.05);
ctx.font = `italic ${authorSize}px 'Georgia', serif`;
ctx.textBaseline = 'bottom';
const authorYOffset = canvas.height - innerPadding - padding * 0.5;
ctx.fillText(author, canvas.width / 2, authorYOffset, canvas.width - (innerPadding * 2) - 20);
// Clean up shadow settings for returning clean canvas state
ctx.shadowColor = 'transparent';
return canvas;
}
Apply Changes