You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(
originalImg,
fullName = "DOE, JOHN N",
dob = "01/01/1990",
dlNum = "D1234567",
expDate = "01/01/2030",
address = "1234 DUMMY STREET, ANYTOWN, CA 90000",
classType = "C",
sex = "M",
height = "5'-08\"",
weight = "160 lb",
hair = "BRN",
eyes = "BRN"
) {
const canvas = document.createElement('canvas');
canvas.width = 1000;
canvas.height = 630;
const ctx = canvas.getContext('2d');
// Background Gradient (Light Blue to Pale Yellow to mock conventional IDs)
const grad = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
grad.addColorStop(0, '#dcedf6');
grad.addColorStop(0.5, '#ffffff');
grad.addColorStop(1, '#faebd7');
ctx.fillStyle = grad;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Security Guilloché-like background pattern (Dummy Pattern)
ctx.lineWidth = 1;
for (let i = 0; i < canvas.width; i += 25) {
ctx.beginPath();
ctx.moveTo(i, 0);
ctx.bezierCurveTo(i + 80, canvas.height / 3, i - 80, 2 * canvas.height / 3, i, canvas.height);
ctx.strokeStyle = "rgba(0, 0, 0, 0.04)";
ctx.stroke();
}
// Top Warning Bar (Ensures dummy status)
ctx.fillStyle = "rgba(220, 50, 50, 0.85)";
ctx.fillRect(0, 0, canvas.width, 35);
ctx.fillStyle = "#fff";
ctx.font = "bold 22px Arial";
ctx.textAlign = "center";
ctx.fillText("DUMMY ID - STRICTLY NOT FOR OFFICIAL USE", canvas.width / 2, 25);
// State Header
ctx.fillStyle = "#164b73";
ctx.font = "bold 65px Georgia, serif";
ctx.textAlign = "center";
ctx.fillText("CALIFORNIA", canvas.width / 2, 105);
ctx.font = "bold 20px Arial";
ctx.fillStyle = "#b22222";
ctx.fillText("USA", 60, 85);
ctx.font = "bold 24px Arial";
ctx.fillStyle = "#000";
ctx.fillText("DRIVER LICENSE", canvas.width / 2, 140);
// Mock Real ID Bear & Star Icon
const iconX = 820;
const iconY = 55;
ctx.fillStyle = "#fdd017";
ctx.fillRect(iconX, iconY, 130, 85);
ctx.fillStyle = "#fff";
ctx.beginPath();
ctx.arc(iconX + 65, iconY + 35, 25, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#000";
ctx.font = "28px Arial";
ctx.fillText("★", iconX + 65, iconY + 45); // Star
ctx.font = "bold 14px Arial";
ctx.fillText("BEAR FLAG", iconX + 65, iconY + 75);
ctx.fillStyle = "#d00000";
ctx.fillRect(iconX, iconY + 85, 130, 10); // Red stripe
// Photography Setup
const photoX = 40;
const photoY = 180;
const photoW = 240;
const photoH = 320;
if (originalImg) {
// Draw Primary Portrait
ctx.drawImage(originalImg, photoX, photoY, photoW, photoH);
// Draw Ghost Portrait in bottom right
ctx.globalAlpha = 0.35;
ctx.drawImage(originalImg, 800, 400, 150, 200);
ctx.globalAlpha = 1.0;
} else {
// Fallback if no image provided
ctx.fillStyle = "#ccc";
ctx.fillRect(photoX, photoY, photoW, photoH);
ctx.fillStyle = "#333";
ctx.font = "20px Arial";
ctx.textAlign = "center";
ctx.fillText("PHOTO", photoX + photoW / 2, photoY + photoH / 2);
}
// Helper for Data Fields
ctx.textAlign = "left";
function drawField(label, value, x, y, valFont, valColor="#000") {
ctx.fillStyle = "#164b73";
ctx.font = "bold 14px Arial";
ctx.fillText(label, x, y);
ctx.fillStyle = valColor;
ctx.font = valFont;
ctx.fillText(value, x + ctx.measureText(label).width + 12, y);
}
let textX = 320;
let textY = 200;
// Line 1: DL and EXP
drawField("DL", dlNum, textX, textY, "bold 32px Arial", "#164b73");
drawField("EXP", expDate, textX + 300, textY, "bold 32px Arial", "#b22222");
// Line 2: Name
textY += 50;
const nameParts = fullName.split(',');
const ln = nameParts[0] ? nameParts[0].trim() : "DOE";
const fn = nameParts[1] ? nameParts[1].trim() : "JOHN N";
drawField("LN", ln, textX, textY, "bold 26px Arial");
textY += 40;
drawField("FN", fn, textX, textY, "bold 26px Arial");
// Line 3: DOB
textY += 50;
drawField("DOB", dob, textX, textY, "bold 28px Arial", "#b22222");
// Line 4: Stats
textY += 50;
ctx.fillStyle = "#164b73";
ctx.font = "bold 16px Arial";
ctx.fillText(`CLASS`, textX, textY);
ctx.fillText(`HAIR`, textX + 110, textY);
ctx.fillText(`EYES`, textX + 220, textY);
ctx.fillText(`HGT`, textX + 330, textY);
ctx.fillText(`WGT`, textX + 440, textY);
ctx.fillStyle = "#000";
ctx.fillText(classType, textX + 60, textY);
ctx.fillText(hair, textX + 155, textY);
ctx.fillText(eyes, textX + 270, textY);
ctx.fillText(height, textX + 375, textY);
ctx.fillText(weight, textX + 485, textY);
// Line 5: Sex & Issuance
textY += 35;
ctx.fillStyle = "#164b73";
ctx.fillText(`SEX`, textX, textY);
ctx.fillStyle = "#000";
ctx.fillText(sex, textX + 40, textY);
ctx.fillStyle = "#164b73";
ctx.fillText(`ISS`, textX + 110, textY);
ctx.fillStyle = "#000";
// Using a derived issue date based roughly on DOB for dummy display
ctx.fillText("01/10/2020", textX + 145, textY);
// Line 6: Address
textY += 50;
const addrParts = address.split(',');
ctx.fillStyle = "#000";
ctx.font = "bold 20px Arial";
ctx.fillText(addrParts[0] ? addrParts[0].trim() : "", textX, textY);
if (addrParts.length > 1) {
let addrLine2 = addrParts.slice(1).join(',').trim();
ctx.fillText(addrLine2, textX, textY + 28);
}
// Signature Line
const sigY = photoY + photoH + 75;
ctx.strokeStyle = "#000";
ctx.lineWidth = 1.5;
ctx.beginPath();
ctx.moveTo(photoX, sigY);
ctx.lineTo(photoX + photoW + 180, sigY);
ctx.stroke();
ctx.font = "italic 40px 'Brush Script MT', 'Palatino Linotype', serif";
ctx.fillStyle = "#333";
ctx.fillText(fn + " " + ln, photoX + 20, sigY - 10);
// Center Safety Watermark
ctx.save();
ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.rotate(-Math.PI / 7);
ctx.fillStyle = "rgba(255, 0, 0, 0.2)";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "bold 160px Arial";
ctx.fillText("DUMMY ID", 0, -30);
ctx.font = "bold 45px Arial";
ctx.fillText("NOT A GOVERNMENT DOCUMENT", 0, 70);
ctx.restore();
// Mock 1D Barcode Pattern (bottom center)
ctx.fillStyle = "#000";
let bcX = 350;
const bcY = canvas.height - 45;
for (let i = 0; i < 70; i++) {
let barW = Math.random() * 5 + 1;
ctx.fillRect(bcX, bcY, barW, 25);
bcX += barW + Math.random() * 4;
if(bcX > 750) break;
}
return canvas;
}
Apply Changes