You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, title = "Spectacular View", author = "Creative Artist", siteName = "GalleryPro") {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// Basic layout dimensions
const padding = 50;
const headerH = 80;
const footerH = 140;
// Scale image responsibly to fit typical UI viewing sizes
const maxImgW = 1000;
const maxImgH = 800;
const imgScale = Math.min(maxImgW / originalImg.width, maxImgH / originalImg.height);
const imgW = originalImg.width * imgScale;
const imgH = originalImg.height * imgScale;
// Calculate final canvas dimensions
// (guaranteeing a minimum width so UI elements have room)
const canvasW = Math.max(800, imgW + padding * 2);
const canvasH = headerH + padding + imgH + padding + footerH;
canvas.width = canvasW;
canvas.height = canvasH;
// 1. Draw Page Background
ctx.fillStyle = '#f3f4f6'; // Light grayish background
ctx.fillRect(0, 0, canvasW, canvasH);
// 2. Draw Header
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, canvasW, headerH);
// Header shadow
ctx.shadowColor = 'rgba(0,0,0,0.08)';
ctx.shadowBlur = 15;
ctx.shadowOffsetY = 4;
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, canvasW, headerH); // Redraw over background to pop out
// Reset shadow
ctx.shadowColor = 'transparent';
ctx.shadowBlur = 0;
ctx.shadowOffsetY = 0;
// 3. Draw Header Elements (Brand Logo & Navigation Links)
ctx.textBaseline = 'middle';
// Logo / Site Name
ctx.fillStyle = '#111827';
ctx.font = 'bold 28px "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
ctx.fillText(siteName, padding, headerH / 2);
// Navigation Text
ctx.font = '600 16px "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
ctx.fillStyle = '#6b7280';
ctx.fillText('Discover', canvasW - padding - 220, headerH / 2);
ctx.fillText('License', canvasW - padding - 130, headerH / 2);
ctx.fillStyle = '#3b82f6'; // Active state color
ctx.fillText('Upload', canvasW - padding - 50, headerH / 2);
// 4. Draw Main Image
const imgX = (canvasW - imgW) / 2;
const imgY = headerH + padding;
// Image Shadow
ctx.shadowColor = 'rgba(0,0,0,0.15)';
ctx.shadowBlur = 20;
ctx.shadowOffsetY = 10;
// To allow rounded corners for the photo, we'll clip
ctx.save();
const borderRadius = 8;
ctx.beginPath();
ctx.roundRect(imgX, imgY, imgW, imgH, borderRadius);
ctx.fill(); // fill to apply the shadow to the box geometry before clipping
// Remove shadow for actual draw & clip to mask corners
ctx.shadowColor = 'transparent';
ctx.clip();
ctx.drawImage(originalImg, imgX, imgY, imgW, imgH);
ctx.restore();
// 5. Draw Footer (Details Area)
const footerY = imgY + imgH + padding;
// Download Button setup
const btnW = 180;
const btnH = 50;
const btnX = canvasW - padding - btnW;
const btnY = footerY;
// Title (left side, constraint width to avoid button overlap)
ctx.fillStyle = '#111827';
ctx.font = 'bold 32px "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
ctx.textBaseline = 'top';
const textMaxWidth = canvasW - padding * 2 - btnW - 30;
ctx.fillText(title, padding, footerY, textMaxWidth);
// Author Info (just below title)
ctx.fillStyle = '#4b5563';
ctx.font = '18px "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
ctx.fillText(`by ${author}`, padding, footerY + 45, textMaxWidth);
// Interaction Stats (Views & Likes mock display)
ctx.fillStyle = '#9ca3af';
ctx.font = '14px "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
const views = Math.floor(Math.random() * 50) + 10;
const likes = (views * Math.random() * 0.3).toFixed(1);
ctx.fillText(`👁 ${views}k views ♥ ${likes}k likes ➕ Save to Gallery`, padding, footerY + 80);
// Draw Download Button Background
ctx.fillStyle = '#10b981'; // Emerald Green
ctx.beginPath();
ctx.roundRect(btnX, btnY, btnW, btnH, 6);
ctx.fill();
ctx.closePath();
// Arrow icon & Text for button
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 16px "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText('⬇ Download Free', btnX + btnW / 2, btnY + btnH / 2);
return canvas;
}
Apply Changes