PNG to ICO (Favicon) Converter

Upload a PNG image to convert it into a multi-resolution ICO (Windows Icon) file, suitable for favicons. Select the desired output sizes.

Image preview will appear here.

Select Output Sizes (pixels):

Image preview will appear here.

'; originalFileName = ""; originalImageBase64 = ""; // Reset checkboxes to default (16x16, 32x32 checked) document.querySelectorAll('input[name="iconSize"]').forEach(cb => { if (cb.value === '16' || cb.value === '32') { cb.checked = true; } else { cb.checked = false; } }); clearResultArea(); } /** * Helper function to clear and hide the result area and PDF button. */ function clearResultArea() { const resultArea = document.getElementById('resultArea'); const downloadPdfButton = document.getElementById('downloadPdfButton'); if (resultArea) { resultArea.style.display = 'none'; resultArea.innerHTML = ''; // Clear stored data for PDF delete resultArea.dataset.inputFileName; delete resultArea.dataset.outputFileName; delete resultArea.dataset.originalImageDimensions; delete resultArea.dataset.convertedSizes; } if (downloadPdfButton) { downloadPdfButton.style.display = 'none'; } } /** * Generates a PDF summary of the conversion. */ function generatePdf() { // Check if jsPDF library is loaded if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { console.error('jsPDF library not loaded. Cannot generate PDF.'); const resultArea = document.getElementById('resultArea'); if (resultArea) { resultArea.innerHTML = '

PDF generation failed. Library not loaded.

'; } return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const resultArea = document.getElementById('resultArea'); // Retrieve stored data for PDF const inputFileName = resultArea.dataset.inputFileName || 'N/A'; const outputFileName = resultArea.dataset.outputFileName || 'N/A'; const originalImageDimensions = resultArea.dataset.originalImageDimensions || 'N/A'; const convertedSizes = JSON.parse(resultArea.dataset.convertedSizes || '[]'); const generationDate = new Date().toLocaleString(); let yOffset = 20; // Title doc.setFontSize(24); doc.setTextColor(44, 62, 80); doc.text("PNG to ICO Conversion Summary", 105, yOffset, { align: 'center' }); yOffset += 20; // Summary details doc.setFontSize(14); doc.setTextColor(51, 51, 51); doc.text(`Conversion Date: ${generationDate}`, 20, yOffset); yOffset += 10; doc.text(`Input File: ${inputFileName}`, 20, yOffset); yOffset += 10; doc.text(`Original Dimensions: ${originalImageDimensions}`, 20, yOffset); yOffset += 10; doc.text(`Output ICO File: ${outputFileName}`, 20, yOffset); yOffset += 10; doc.text(`Converted Sizes Included: ${convertedSizes.length > 0 ? convertedSizes.join('x, ') + 'x' : 'None'}`, 20, yOffset); yOffset += 20; // Conversion Notes doc.setFontSize(12); doc.setTextColor(80, 80, 80); doc.text("Important Notes on ICO Conversion:", 20, yOffset); yOffset += 7; const notes = [ "• This tool creates an ICO file containing multiple uncompressed 32-bit (BGRA) images.", "• Each selected size is a separate image embedded within the ICO file.", "• Transparency (alpha channel) from the PNG is preserved using an XOR/AND mask approach for compatibility.", "• For optimal favicon performance and smallest file size, ensure your original PNG has appropriate dimensions and transparent background if desired." ]; notes.forEach(note => { const splitNote = doc.splitTextToSize(note, 170); doc.text(splitNote, 25, yOffset); yOffset += (splitNote.length * 7) + 5; }); yOffset += 15; // Footer doc.setFontSize(9); doc.setTextColor(150, 150, 150); doc.text(`Report Generated by PNG to ICO Converter Tool`, 20, doc.internal.pageSize.height - 15); doc.save("PNG_to_ICO_Conversion_Summary.pdf"); }
Scroll to Top