You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, text = "Праздник подарков!", themeColor = "#ff4757", fontSize = 80, showEmbellishments = 1) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const width = originalImg.width;
const height = originalImg.height;
canvas.width = width;
canvas.height = height;
// Draw original image
ctx.drawImage(originalImg, 0, 0, width, height);
// Calculate relative scales based on image size
const minDim = Math.min(width, height);
const scale = minDim / 1000;
// 1. Draw Festive Border Frame
const frameWidth = Math.max(15, minDim * 0.04);
ctx.lineWidth = frameWidth;
ctx.strokeStyle = themeColor;
ctx.strokeRect(frameWidth / 2, frameWidth / 2, width - frameWidth, height - frameWidth);
// Inner dashed golden border
ctx.lineWidth = Math.max(4, frameWidth * 0.15);
ctx.strokeStyle = "#ffd32a";
ctx.setLineDash([frameWidth, frameWidth * 0.75]);
ctx.strokeRect(frameWidth * 1.5, frameWidth * 1.5, width - frameWidth * 3, height - frameWidth * 3);
ctx.setLineDash([]);
// 2. Draw Embellishments (Gifts, Balloons, Confetti Emojis)
if (Number(showEmbellishments) === 1) {
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
const emojiSize = Math.max(30, minDim * 0.12);
ctx.font = `${emojiSize}px Arial, sans-serif`;
// Corner Balloons & Party Poppers
const offset = frameWidth * 2.5 + emojiSize / 2;
ctx.fillText("🎈", offset, offset);
ctx.fillText("🎉", width - offset, offset);
// Bottom Row of Gifts
const giftCount = 5;
for (let i = 1; i < giftCount; i++) {
const x = (width / giftCount) * i;
// Slight wave pattern for gifts
const yOffset = Math.sin(i * Math.PI / 2) * (emojiSize * 0.2);
const y = height - frameWidth * 2 - emojiSize / 2 + yOffset;
// Alternate gift/sparkle
const icon = (i % 2 === 0) ? "✨" : "🎁";
ctx.fillText(icon, x, y);
}
}
// 3. Draw Corner Present Ribbon (Top-Left)
const cornerSize = Math.max(100, minDim * 0.3);
const ribbonW = cornerSize * 0.3;
ctx.save();
ctx.beginPath();
ctx.moveTo(0, cornerSize - ribbonW);
ctx.lineTo(cornerSize - ribbonW, 0);
ctx.lineTo(cornerSize, 0);
ctx.lineTo(0, cornerSize);
ctx.closePath();
// Ribbon shadow
ctx.shadowColor = 'rgba(0, 0, 0, 0.4)';
ctx.shadowBlur = 10;
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.fillStyle = themeColor;
ctx.fill();
// Ribbon Text
ctx.shadowColor = 'transparent';
const textMidPoint = (cornerSize - ribbonW / 2) / 2;
ctx.translate(textMidPoint, textMidPoint);
ctx.rotate(-Math.PI / 4);
ctx.fillStyle = "#ffffff";
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = `bold ${ribbonW * 0.4}px Arial, sans-serif`;
ctx.fillText("FOR YOU", 0, 0);
ctx.restore();
// 4. Add Central Festive Text Banner
if (text && text.trim() !== '') {
const actualFontSize = Math.max(20, scale * fontSize);
ctx.font = `bold ${actualFontSize}px 'Trebuchet MS', Arial, sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
const textX = width / 2;
// Position above the bottom gifts
const bottomPadding = Number(showEmbellishments) === 1 ? Math.max(30, minDim * 0.12) : 0;
const textY = height - frameWidth * 3.5 - bottomPadding;
// Add glowing shadow behind text for readability over any background
ctx.shadowColor = 'rgba(0, 0, 0, 0.7)';
ctx.shadowBlur = Math.max(5, actualFontSize * 0.2);
ctx.shadowOffsetX = 3;
ctx.shadowOffsetY = 3;
// White Fill
ctx.fillStyle = "#ffffff";
ctx.fillText(text, textX, textY);
// Remove shadow for the stroke
ctx.shadowColor = 'transparent';
ctx.shadowBlur = 0;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
// Theme Color Outline
ctx.lineWidth = Math.max(2, actualFontSize * 0.05);
ctx.strokeStyle = themeColor;
ctx.strokeText(text, textX, textY);
// Second inner outline for pop effect
ctx.lineWidth = Math.max(1, actualFontSize * 0.015);
ctx.strokeStyle = "#ffd32a"; // Gold
ctx.strokeText(text, textX, textY);
}
return canvas;
}
Apply Changes