You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, mode = 'ID Template', includeDummyText = 'true') {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// Mdoe 1: Generate only the specific background color/gradient used in Ohio DL photos
if (mode.toLowerCase() === 'photo backdrop only') {
canvas.width = originalImg.width || 600;
canvas.height = originalImg.height || 800;
// Ohio BMV typical light blue photo backdrop gradient
const bgGrad = ctx.createRadialGradient(
canvas.width / 2, canvas.height / 2, canvas.height / 4,
canvas.width / 2, canvas.height / 2, canvas.height
);
bgGrad.addColorStop(0, '#a5ccdf');
bgGrad.addColorStop(1, '#7eaecf');
ctx.fillStyle = bgGrad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Add a subtle vignette/texture
ctx.fillStyle = 'rgba(0, 0, 0, 0.03)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);
return canvas;
}
// Mode 2: Generate Full Ohio Driver's License Background Template
canvas.width = 860;
canvas.height = 540;
// 1. Base Gradient Layer (Pastel Blue, Green, Pink)
const baseGrad = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
baseGrad.addColorStop(0, '#eaf2f8');
baseGrad.addColorStop(0.5, '#e8f3ec');
baseGrad.addColorStop(1, '#faeef2');
ctx.fillStyle = baseGrad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// 2. Guilloche / Intricate Security Wavy Patterns
const drawSecurityWaves = (color, yOffset, freq1, freq2, amp1, amp2) => {
ctx.beginPath();
ctx.strokeStyle = color;
ctx.lineWidth = 1;
for (let i = 0; i < 40; i++) {
for (let x = 0; x <= canvas.width; x += 5) {
let y = yOffset + i * 18 + Math.sin(x / freq1 + i) * amp1 + Math.cos(x / freq2) * amp2;
if (x === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
}
ctx.stroke();
};
drawSecurityWaves('rgba(150, 180, 220, 0.15)', -100, 60, 100, 20, 15);
drawSecurityWaves('rgba(230, 160, 180, 0.15)', 30, 80, 120, 25, 20);
drawSecurityWaves('rgba(160, 210, 180, 0.12)', 150, 70, 90, 15, 25);
// 3. Central Background Elements (State Seal Placeholder & Watermark)
ctx.save();
ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate(-Math.PI / 8);
ctx.font = 'bold 120px "Arial Black", Arial, sans-serif';
ctx.fillStyle = 'rgba(255, 255, 255, 0.6)';
ctx.textAlign = 'center';
ctx.fillText('OHIO', 0, 40);
ctx.restore();
ctx.save();
ctx.globalAlpha = 0.08;
ctx.beginPath();
ctx.arc(canvas.width / 2 + 50, canvas.height / 2, 120, 0, Math.PI * 2);
ctx.fillStyle = '#000';
ctx.fill();
ctx.lineWidth = 5;
ctx.stroke();
ctx.font = 'bold 30px Arial';
ctx.textAlign = 'center';
ctx.fillStyle = '#000';
ctx.fillText('STATE OF OHIO', canvas.width / 2 + 50, canvas.height / 2 - 20);
ctx.fillText('SEAL', canvas.width / 2 + 50, canvas.height / 2 + 20);
ctx.restore();
// 4. Header Section
ctx.fillStyle = 'rgba(235, 100, 120, 0.6)'; // Stylized salmon/pink wave at the top
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(canvas.width, 0);
ctx.lineTo(canvas.width, 65);
ctx.quadraticCurveTo(canvas.width / 2, 100, 0, 65);
ctx.fill();
ctx.font = 'bold 44px "Arial Black", Arial, sans-serif';
ctx.fillStyle = '#b31b1b'; // Distinctive dark red
ctx.textAlign = 'left';
ctx.fillText('OHIO', 270, 50);
ctx.font = 'bold 20px Arial';
ctx.fillStyle = '#333';
ctx.fillText('DRIVER LICENSE', 410, 46);
ctx.fillStyle = '#555';
ctx.font = '14px Arial';
ctx.fillText('USA', 600, 46);
// Real ID Golden Star Placeholder
ctx.beginPath();
let cx = 780, cy = 40, outerRad = 16, innerRad = 8, spikes = 5, rot = Math.PI / 2 * 3;
let sx = cx, sy = cy, step = Math.PI / spikes;
ctx.moveTo(cx, cy - outerRad);
for (let i = 0; i < spikes; i++) {
sx = cx + Math.cos(rot) * outerRad; sy = cy + Math.sin(rot) * outerRad;
ctx.lineTo(sx, sy); rot += step;
sx = cx + Math.cos(rot) * innerRad; sy = cy + Math.sin(rot) * innerRad;
ctx.lineTo(sx, sy); rot += step;
}
ctx.lineTo(cx, cy - outerRad);
ctx.closePath();
ctx.fillStyle = '#d4af37';
ctx.fill();
// 5. Draw Primary Profile Photo (Left Side)
const photoX = 40;
const photoY = 110;
const photoW = 200;
const photoH = 260;
// Put standard ohio backdrop behind image in case originalImg has transparent background
const portraitGrad = ctx.createRadialGradient(
photoX + photoW / 2, photoY + photoH / 2, photoH / 4,
photoX + photoW / 2, photoY + photoH / 2, photoH
);
portraitGrad.addColorStop(0, '#a5ccdf');
portraitGrad.addColorStop(1, '#7eaecf');
ctx.fillStyle = portraitGrad;
ctx.fillRect(photoX, photoY, photoW, photoH);
// Draw provided portrait image
if (originalImg) {
ctx.drawImage(originalImg, photoX, photoY, photoW, photoH);
}
// Overlapping ghost photo (bottom right standard security feature)
if (originalImg) {
ctx.globalAlpha = 0.35;
const ghostW = 90;
const ghostH = 117;
const ghostX = 720;
const ghostY = 380;
ctx.drawImage(originalImg, ghostX, ghostY, ghostW, ghostH);
ctx.globalAlpha = 1.0;
}
// 6. Draw Placeholder Data Text Fields
if (includeDummyText.toString().toLowerCase() === 'true') {
const drawField = (num, label, value, x, y) => {
ctx.fillStyle = '#b31b1b';
ctx.font = 'bold 11px Arial';
ctx.fillText(num, x, y);
ctx.fillStyle = '#000';
ctx.font = 'bold 16px Arial';
ctx.fillText(value, x + 18, y);
};
drawField('1', 'Lic No.', 'AB123456', 260, 130);
drawField('2', 'Name', 'DOE, JOHN A', 260, 160);
drawField('8', 'Address', '123 BUCKEYE WAY', 260, 190);
drawField('', '', 'COLUMBUS, OH 43215', 278, 210);
drawField('3', 'DOB', '01/01/1980', 260, 250);
drawField('4a', 'ISS', '10/10/2022', 420, 250);
drawField('4b', 'EXP', '01/01/2026', 260, 280);
drawField('9', 'Class', 'D', 420, 280);
ctx.font = 'bold 11px Arial';
ctx.fillStyle = '#b31b1b';
ctx.fillText('15 SEX', 260, 315);
ctx.fillStyle = '#000';
ctx.fillText('M', 310, 315);
ctx.fillStyle = '#b31b1b';
ctx.fillText('16 HGT', 340, 315);
ctx.fillStyle = '#000';
ctx.fillText('5-10', 390, 315);
ctx.fillStyle = '#b31b1b';
ctx.fillText('18 EYES', 430, 315);
ctx.fillStyle = '#000';
ctx.fillText('BLU', 485, 315);
// Signature
ctx.beginPath();
ctx.strokeStyle = '#000';
ctx.lineWidth = 1;
ctx.moveTo(260, 390);
ctx.lineTo(550, 390);
ctx.stroke();
ctx.font = 'italic 28px "Times New Roman", serif';
ctx.fillStyle = '#000';
ctx.fillText('John A Doe', 300, 380);
ctx.font = 'bold 11px Arial';
ctx.fillStyle = '#b31b1b';
ctx.fillText('9 SIGNATURE', 260, 405);
}
return canvas;
}
Apply Changes