You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, placeholderText = 'Search Topic Google Android Telephone', audioUrl = '') {
// Create the main device container (mocking an Android Telephone constraint)
const phoneContainer = document.createElement('div');
phoneContainer.style.width = '360px';
phoneContainer.style.height = '640px';
phoneContainer.style.backgroundColor = '#121212';
phoneContainer.style.borderRadius = '30px';
phoneContainer.style.overflow = 'hidden';
phoneContainer.style.fontFamily = '"Roboto", "Helvetica Neue", Arial, sans-serif';
phoneContainer.style.display = 'flex';
phoneContainer.style.flexDirection = 'column';
phoneContainer.style.boxShadow = '0 10px 35px rgba(0,0,0,0.7), inset 0 0 0 5px #333';
phoneContainer.style.margin = '20px auto';
phoneContainer.style.position = 'relative';
// Mock Status Bar
const statusBar = document.createElement('div');
statusBar.style.height = '24px';
statusBar.style.backgroundColor = 'rgba(0,0,0,0.5)';
statusBar.style.display = 'flex';
statusBar.style.justifyContent = 'space-between';
statusBar.style.alignItems = 'center';
statusBar.style.padding = '0 15px';
statusBar.style.color = '#fff';
statusBar.style.fontSize = '12px';
const time = new Date();
const timeStr = time.getHours() + ':' + (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
statusBar.innerHTML = `<span>${timeStr}</span><span>📶 🔋</span>`;
phoneContainer.appendChild(statusBar);
// Header / Search Area
const header = document.createElement('div');
header.style.padding = '15px';
header.style.backgroundColor = '#1e1e1e';
header.style.display = 'flex';
header.style.gap = '10px';
header.style.borderBottom = '1px solid #333';
const searchInput = document.createElement('input');
searchInput.type = 'text';
searchInput.placeholder = placeholderText;
searchInput.style.flex = '1';
searchInput.style.padding = '10px 15px';
searchInput.style.borderRadius = '20px';
searchInput.style.border = '1px solid #444';
searchInput.style.backgroundColor = '#2c2c2c';
searchInput.style.color = '#fff';
searchInput.style.outline = 'none';
const searchBtn = document.createElement('button');
searchBtn.innerText = '🔍';
searchBtn.style.background = 'none';
searchBtn.style.border = 'none';
searchBtn.style.color = 'white';
searchBtn.style.cursor = 'pointer';
searchBtn.style.fontSize = '18px';
header.appendChild(searchInput);
header.appendChild(searchBtn);
phoneContainer.appendChild(header);
// Middle Section: Album Art & Title
const contentSection = document.createElement('div');
contentSection.style.flex = '1';
contentSection.style.display = 'flex';
contentSection.style.flexDirection = 'column';
contentSection.style.justifyContent = 'center';
contentSection.style.alignItems = 'center';
contentSection.style.background = 'linear-gradient(180deg, #1e1e1e 0%, #121212 100%)';
// Album Art (using originalImg mapped into Canvas for robust layout control)
const canvas = document.createElement('canvas');
const artSize = 250;
canvas.width = artSize;
canvas.height = artSize;
const ctx = canvas.getContext('2d');
// Create a rounded rectangle for album cover clipping
const radius = 15;
ctx.beginPath();
ctx.moveTo(radius, 0);
ctx.lineTo(artSize - radius, 0);
ctx.quadraticCurveTo(artSize, 0, artSize, radius);
ctx.lineTo(artSize, artSize - radius);
ctx.quadraticCurveTo(artSize, artSize, artSize - radius, artSize);
ctx.lineTo(radius, artSize);
ctx.quadraticCurveTo(0, artSize, 0, artSize - radius);
ctx.lineTo(0, radius);
ctx.quadraticCurveTo(0, 0, radius, 0);
ctx.closePath();
ctx.clip();
// Scale and center the original image appropriately
const scale = Math.max(artSize / originalImg.width, artSize / originalImg.height);
const drawWidth = originalImg.width * scale;
const drawHeight = originalImg.height * scale;
const drawX = (artSize - drawWidth) / 2;
const drawY = (artSize - drawHeight) / 2;
ctx.drawImage(originalImg, drawX, drawY, drawWidth, drawHeight);
canvas.style.boxShadow = '0 15px 35px rgba(0,0,0,0.6)';
canvas.style.borderRadius = '15px';
contentSection.appendChild(canvas);
// Title / Audio information Area
const titleArea = document.createElement('div');
titleArea.style.textAlign = 'center';
titleArea.style.color = '#fff';
titleArea.style.marginTop = '30px';
titleArea.style.width = '85%';
const titleText = document.createElement('h2');
titleText.innerText = 'No Track Selected';
titleText.style.margin = '0 0 8px 0';
titleText.style.fontSize = '22px';
titleText.style.whiteSpace = 'nowrap';
titleText.style.overflow = 'hidden';
titleText.style.textOverflow = 'ellipsis';
const subText = document.createElement('p');
subText.innerText = 'Search for a topic above.';
subText.style.margin = '0';
subText.style.fontSize = '14px';
subText.style.color = '#aaaaaa';
titleArea.appendChild(titleText);
titleArea.appendChild(subText);
contentSection.appendChild(titleArea);
phoneContainer.appendChild(contentSection);
// Bottom Section: Web Audio Player Controls
const playerArea = document.createElement('div');
playerArea.style.padding = '25px 20px';
playerArea.style.backgroundColor = '#121212';
playerArea.style.borderTop = '1px solid #222';
const audio = document.createElement('audio');
audio.controls = true;
audio.src = audioUrl; // Fills depending on argument
audio.style.width = '100%';
audio.style.outline = 'none';
playerArea.appendChild(audio);
phoneContainer.appendChild(playerArea);
// Dynamic Mock Search Interactivity
searchBtn.addEventListener('click', () => {
const query = searchInput.value.trim();
if (query) {
titleText.innerText = query;
subText.innerText = 'Requesting audio streams...';
// Mocking search resolution
setTimeout(() => {
subText.innerText = 'No audio stream returned. Ready for playback.';
}, 1000);
}
});
searchInput.addEventListener('keyup', (e) => {
if (e.key === 'Enter') {
searchBtn.click();
}
});
return phoneContainer;
}
Apply Changes