You can edit the below JavaScript code to customize the image tool.
Apply Changes
async function processImage(originalImg, title = "THE EPIC MOVIE", tagline = "A Journey Beyond Imagination", cast = "LEAD ACTOR SUPPORTING ACTOR", date = "COMING SOON", themeColor = "#e6b91e") {
// Create and configure the canvas (standard movie poster aspect ratio 2:3)
const canvas = document.createElement('canvas');
canvas.width = 800;
canvas.height = 1200;
const ctx = canvas.getContext('2d');
// Calculate crop dimensions to ensure image covers the canvas (center focus)
const imgAspect = originalImg.width / originalImg.height;
const canvasAspect = canvas.width / canvas.height;
let sWidth, sHeight, sx, sy;
if (imgAspect > canvasAspect) {
sHeight = originalImg.height;
sWidth = sHeight * canvasAspect;
sx = (originalImg.width - sWidth) / 2;
sy = 0;
} else {
sWidth = originalImg.width;
sHeight = sWidth / canvasAspect;
sx = 0;
sy = (originalImg.height - sHeight) / 2;
}
// Draw the cropped image
ctx.drawImage(originalImg, sx, sy, sWidth, sHeight, 0, 0, canvas.width, canvas.height);
// Apply a cinematic soft dark overlay to add contrast
ctx.globalCompositeOperation = 'soft-light';
ctx.fillStyle = 'rgba(0, 0, 0, 0.4)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.globalCompositeOperation = 'source-over';
// Gradients to ensure text visibility
const gradTop = ctx.createLinearGradient(0, 0, 0, 250);
gradTop.addColorStop(0, 'rgba(0, 0, 0, 0.85)');
gradTop.addColorStop(1, 'rgba(0, 0, 0, 0)');
ctx.fillStyle = gradTop;
ctx.fillRect(0, 0, canvas.width, 250);
const gradBottom = ctx.createLinearGradient(0, canvas.height - 700, 0, canvas.height);
gradBottom.addColorStop(0, 'rgba(0, 0, 0, 0)');
gradBottom.addColorStop(0.6, 'rgba(0, 0, 0, 0.85)');
gradBottom.addColorStop(1, 'rgba(0, 0, 0, 1)');
ctx.fillStyle = gradBottom;
ctx.fillRect(0, canvas.height - 700, canvas.width, 700);
// Dynamically load Google Fonts needed for typical modern movie posters
const linkId = 'googleapis-movie-poster-fonts';
if (!document.getElementById(linkId)) {
const link = document.createElement('link');
link.id = linkId;
link.href = 'https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Oswald:wght@300;400;700&display=swap';
link.rel = 'stylesheet';
document.head.appendChild(link);
}
// Wait briefly for the font definitions to be fetched
await new Promise(resolve => setTimeout(resolve, 500));
try {
await document.fonts.load('120px "Bebas Neue"');
await document.fonts.load('40px "Oswald"');
} catch (e) {
// Fallback silently if fonts fail to load
console.warn("Fonts might not be fully loaded:", e);
}
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
// --- Cast Text ---
if ('letterSpacing' in ctx) ctx.letterSpacing = '5px';
ctx.font = '300 24px "Oswald", sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText(cast.toUpperCase(), canvas.width / 2, 80);
// --- Title Text ---
if ('letterSpacing' in ctx) ctx.letterSpacing = '10px';
let titleSize = 130;
ctx.font = `${titleSize}px "Bebas Neue", sans-serif`;
// Scale down text if it's too wide
while (ctx.measureText(title.toUpperCase()).width > canvas.width - 100 && titleSize > 40) {
titleSize -= 5;
ctx.font = `${titleSize}px "Bebas Neue", sans-serif`;
}
ctx.fillStyle = '#ffffff';
ctx.shadowColor = 'rgba(0,0,0,0.9)';
ctx.shadowBlur = 25;
ctx.shadowOffsetY = 5;
ctx.fillText(title.toUpperCase(), canvas.width / 2, canvas.height - 350);
// Reset shadow properties so they don't apply to the rest of the text
ctx.shadowColor = 'transparent';
ctx.shadowBlur = 0;
ctx.shadowOffsetY = 0;
// --- Tagline Text ---
if ('letterSpacing' in ctx) ctx.letterSpacing = '3px';
let tagSize = 36;
ctx.font = `300 ${tagSize}px "Oswald", sans-serif`;
while (ctx.measureText(tagline).width > canvas.width - 100 && tagSize > 20) {
tagSize -= 2;
ctx.font = `300 ${tagSize}px "Oswald", sans-serif`;
}
ctx.fillStyle = themeColor;
ctx.fillText(tagline, canvas.width / 2, canvas.height - 240);
// --- Movie Billing Block Text ---
// Simulating condensed credit text typical of movie posters
if ('letterSpacing' in ctx) ctx.letterSpacing = '1px';
const billingText = "PRODUCED BY CINEMA CORP DIRECTED BY VISIONARY DIRECTOR WRITTEN BY GREAT WRITER MUSIC BY EPIC COMPOSER\nDIRECTOR OF PHOTOGRAPHY LENS MASTER EDITED BY SHARP SCISSORS PRODUCTION DESIGNER SET BUILDER";
const billingLines = billingText.split('\n');
ctx.save();
ctx.translate(canvas.width / 2, canvas.height - 150);
// Compressing width to simulate typical tall & thin typography seen in billing blocks
ctx.scale(0.55, 1.2);
ctx.font = '400 18px "Arial", sans-serif';
ctx.fillStyle = 'rgba(255, 255, 255, 0.5)';
billingLines.forEach((line, i) => {
ctx.fillText(line, 0, i * 25);
});
ctx.restore();
// --- Release Date Text ---
if ('letterSpacing' in ctx) ctx.letterSpacing = '8px';
ctx.font = '50px "Bebas Neue", sans-serif';
ctx.fillStyle = themeColor;
ctx.fillText(date.toUpperCase(), canvas.width / 2, canvas.height - 60);
return canvas;
}
Apply Changes