You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(
originalImg,
domainName = "admin.example.com",
dbName = "Production DB",
siteName = "Main Corporate Site",
interfaceName = "Web Control Panel",
ipAddress = "10.0.0.51"
) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// Make sure the canvas is wide enough to display text elegantly
const minWidth = 600;
const maxWidth = 1600;
let width = originalImg.width;
let height = originalImg.height;
if (width < minWidth) {
const scale = minWidth / width;
width = minWidth;
height = height * scale;
} else if (width > maxWidth) {
const scale = maxWidth / width;
width = maxWidth;
height = height * scale;
}
// Dynamic UI component scales
const topBarHeight = Math.min(120, Math.max(50, width * 0.06));
const bottomBarHeight = Math.max(70, width * 0.08);
const radius = topBarHeight * 0.2;
canvas.width = width;
canvas.height = height + topBarHeight + bottomBarHeight;
// Helper for browser window shape
function drawRoundRect(context, x, y, w, h, radii) {
const [tl, tr, br, bl] = radii;
context.beginPath();
context.moveTo(x + tl, y);
context.lineTo(x + w - tr, y);
context.quadraticCurveTo(x + w, y, x + w, y + tr);
context.lineTo(x + w, y + h - br);
context.quadraticCurveTo(x + w, y + h, x + w - br, y + h);
context.lineTo(x + bl, y + h);
context.quadraticCurveTo(x, y + h, x, y + h - bl);
context.lineTo(x, y + tl);
context.quadraticCurveTo(x, y, x + tl, y);
context.closePath();
}
// Apply main clip area with rounded corners
drawRoundRect(ctx, 0, 0, canvas.width, canvas.height, [radius, radius, radius, radius]);
ctx.clip();
// Fill a white background to support transparent images cleanly
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// ==========================================
// 1. TOP BAR (BROWSER ADDRESS INTERFACE)
// ==========================================
ctx.fillStyle = '#f5f5f5';
ctx.fillRect(0, 0, width, topBarHeight);
ctx.fillStyle = '#dcdcdc'; // Separator line beneath top bar
ctx.fillRect(0, topBarHeight - 1, width, 1);
// Window control buttons
const dotRadius = topBarHeight * 0.15;
const dotY = topBarHeight / 2;
let dotX = topBarHeight * 0.4;
const dotSpacing = dotRadius * 3.5;
['#ff5f56', '#ffbd2e', '#27c93f'].forEach(color => {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(dotX, dotY, dotRadius, 0, Math.PI * 2);
ctx.fill();
dotX += dotSpacing;
});
// Domain / Address bar
const addrWidth = width * 0.5;
const addrHeight = topBarHeight * 0.55;
const addrX = (width - addrWidth) / 2;
const addrY = (topBarHeight - addrHeight) / 2;
const addrRadius = addrHeight / 2;
ctx.fillStyle = '#ffffff';
drawRoundRect(ctx, addrX, addrY, addrWidth, addrHeight, [addrRadius, addrRadius, addrRadius, addrRadius]);
ctx.fill();
// Domain Text
ctx.fillStyle = '#555555';
const topFontSize = addrHeight * 0.45;
ctx.font = `${topFontSize}px sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
const domainText = `🔒 ${String(domainName)}`;
const maxDomainWidth = addrWidth - topFontSize * 2;
ctx.fillText(domainText, width / 2, topBarHeight / 2 + topFontSize * 0.05, maxDomainWidth);
// ==========================================
// 2. ORIGINAL IMAGE CONTENT
// ==========================================
ctx.drawImage(originalImg, 0, topBarHeight, width, height);
// ==========================================
// 3. BOTTOM BAR (DATABASE & SYSTEM DETAILS)
// ==========================================
const yOffset = topBarHeight + height;
ctx.fillStyle = '#1e293b'; // Slate dark background
ctx.fillRect(0, yOffset, width, bottomBarHeight);
ctx.fillStyle = '#0f172a'; // Top separator for bottom bar
ctx.fillRect(0, yOffset, width, 2);
const paddingX = width * 0.04;
const colSpacing = width * 0.48; // Space between columns
const row1Y = yOffset + bottomBarHeight * 0.33;
const row2Y = yOffset + bottomBarHeight * 0.67;
const labelColor = '#94a3b8';
const valueColor = '#f8fafc';
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
const textFontSize = bottomBarHeight * 0.22;
function drawInfoPair(label, value, x, y) {
// Draw bold Label
ctx.font = `bold ${textFontSize}px sans-serif`;
ctx.fillStyle = labelColor;
const prefix = `${label}: `;
ctx.fillText(prefix, x, y);
// Draw Value next to it
const labelWidth = ctx.measureText(prefix).width;
ctx.font = `normal ${textFontSize}px sans-serif`;
ctx.fillStyle = valueColor;
const valString = String(value);
let maxValWidth = (width * 0.45) - labelWidth - 10;
if (maxValWidth <= 0) maxValWidth = 50; // Fallback
ctx.fillText(valString, x + labelWidth, y, maxValWidth);
}
// Grid details (match required descriptions exactly)
drawInfoPair("Сайт", siteName, paddingX, row1Y);
drawInfoPair("База данных", dbName, paddingX + colSpacing, row1Y);
drawInfoPair("Веб интерфейс", interfaceName, paddingX, row2Y);
drawInfoPair("Адрес", ipAddress, paddingX + colSpacing, row2Y);
return canvas;
}
Apply Changes