You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, songTitle = "Unknown Track", artistName = "Unknown Artist", searchText = "Search Topic Music Audio File Player Mp3 Song Lyric Vector Image Png") {
// Create canvas and setup dimensions for our 'player UI'
const canvas = document.createElement("canvas");
const width = 800;
const height = 400;
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
// Helper function to draw rounded rectangles
function roundRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
// 1. Draw blurred background
const scale = Math.max(width / originalImg.width, height / originalImg.height);
const bgW = originalImg.width * scale;
const bgH = originalImg.height * scale;
const bgX = (width - bgW) / 2;
const bgY = (height - bgH) / 2;
ctx.save();
ctx.filter = 'blur(15px) brightness(0.6)';
ctx.drawImage(originalImg, bgX, bgY, bgW, bgH);
ctx.restore();
// Dark overlay for better text contrast
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
ctx.fillRect(0, 0, width, height);
// 2. Draw Top Search Bar
const searchX = 40;
const searchY = 30;
const searchW = 720;
const searchH = 44;
const searchR = 22;
roundRect(ctx, searchX, searchY, searchW, searchH, searchR);
ctx.fillStyle = 'rgba(255, 255, 255, 0.15)';
ctx.fill();
ctx.strokeStyle = 'rgba(255, 255, 255, 0.3)';
ctx.lineWidth = 1;
ctx.stroke();
// Search Icon & Text
ctx.fillStyle = '#ffffff';
ctx.font = '16px Arial, sans-serif';
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
// Magnifying glass emoji + search text
ctx.fillText("🔍 " + searchText.substring(0, 85) + (searchText.length > 85 ? "..." : ""), searchX + 20, searchY + searchH / 2);
// 3. Draw Album Cover (Square, left aligned)
const albumSize = 220;
const albumX = 40;
const albumY = 110;
const albumR = 15;
ctx.save();
roundRect(ctx, albumX, albumY, albumSize, albumSize, albumR);
ctx.clip();
// Scale original image to cover the square album box
const srcSize = Math.min(originalImg.width, originalImg.height);
const srcX = (originalImg.width - srcSize) / 2;
const srcY = (originalImg.height - srcSize) / 2;
ctx.drawImage(originalImg, srcX, srcY, srcSize, srcSize, albumX, albumY, albumSize, albumSize);
ctx.restore();
// Album subtle border
roundRect(ctx, albumX, albumY, albumSize, albumSize, albumR);
ctx.strokeStyle = 'rgba(255, 255, 255, 0.2)';
ctx.stroke();
// 4. Draw Song Info
const textX = 300;
let textY = 145;
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 34px sans-serif';
ctx.textBaseline = 'top';
ctx.fillText(songTitle, textX, textY);
textY += 45;
ctx.fillStyle = '#cccccc';
ctx.font = '22px sans-serif';
ctx.fillText(artistName, textX, textY);
// 5. Draw Progress Bar
const progressY = 240;
const progressW = 460;
const progressFill = 0.35; // 35% played
// Background track
roundRect(ctx, textX, progressY, progressW, 6, 3);
ctx.fillStyle = 'rgba(255, 255, 255, 0.2)';
ctx.fill();
// Filled track
roundRect(ctx, textX, progressY, progressW * progressFill, 6, 3);
ctx.fillStyle = '#1db954'; // A familiar green hint
ctx.fill();
// Playhead thumb
ctx.beginPath();
ctx.arc(textX + progressW * progressFill, progressY + 3, 7, 0, Math.PI * 2);
ctx.fillStyle = '#ffffff';
ctx.fill();
// Timestamps
ctx.fillStyle = '#aaaaaa';
ctx.font = '14px sans-serif';
ctx.fillText("1:15", textX, progressY + 15);
ctx.textAlign = 'right';
ctx.fillText("3:34", textX + progressW, progressY + 15);
// 6. Draw Player Controls
// Space between album and right side is 500px, center is 300 + 460/2 = 530
const cx = 530;
const cy = 310;
// Play Button (Circle)
ctx.beginPath();
ctx.arc(cx, cy, 30, 0, Math.PI * 2);
ctx.fillStyle = '#ffffff';
ctx.fill();
// Play Button (Triangle inside)
ctx.beginPath();
ctx.moveTo(cx - 8, cy - 12);
ctx.lineTo(cx + 14, cy);
ctx.lineTo(cx - 8, cy + 12);
ctx.closePath();
ctx.fillStyle = '#000000';
ctx.fill();
// Previous Track Button
ctx.fillStyle = '#ffffff';
ctx.beginPath();
ctx.moveTo(cx - 60, cy);
ctx.lineTo(cx - 45, cy - 12);
ctx.lineTo(cx - 45, cy + 12);
ctx.fill();
ctx.fillRect(cx - 64, cy - 12, 4, 24);
// Next Track Button
ctx.beginPath();
ctx.moveTo(cx + 60, cy);
ctx.lineTo(cx + 45, cy - 12);
ctx.lineTo(cx + 45, cy + 12);
ctx.fill();
ctx.fillRect(cx + 60, cy - 12, 4, 24);
return canvas;
}
Apply Changes