Compress images online in seconds with our fast, secure Image Compressor Tool. Reduce image file size without losing quality, improve website speed, boost SEO performance, and optimize images for web, mobile, and social media—no registration required.
`; grid.appendChild(card); } function downloadSingle(imageName) { const image = images.find(img => img.name === imageName); if (!image) return; const link = document.createElement('a'); link.href = image.url; link.download = 'compressed_' + image.name; document.body.appendChild(link); link.click(); document.body.removeChild(link); showToast('Downloaded: ' + image.name); } function downloadAll() { if (images.length === 0) { showToast('No images to download'); return; } images.forEach((image, index) => { setTimeout(() => { downloadSingle(image.name); }, index * 300); }); showToast('Downloading ' + images.length + ' files...'); } function updateProgress() { // Simple progress update const total = images.length; document.getElementById('imageCount').textContent = total; } function updateStats() { let totalSaved = 0; images.forEach(img => { totalSaved += img.originalSize - img.compressedSize; }); document.getElementById('savedSize').textContent = formatBytes(totalSaved); } function formatBytes(bytes) { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; } function showToast(message) { const toast = document.getElementById('toast'); toast.textContent = message; toast.style.display = 'block'; setTimeout(() => { toast.style.display = 'none'; }, 3000); }
Leave a Comment