Image resizer

Image Resizer Tool

Download Resized Image
image.'); return; } const conversionFactor = getConversionFactor(units); const widthInPixels = width * conversionFactor; const heightInPixels = height * conversionFactor; const file = fileInput.files[0]; const reader = new FileReader(); reader.onload = function(event) { const img = new Image(); img.onload = function() { canvas.width = widthInPixels; canvas.height = heightInPixels; ctx.drawImage(img, 0, 0, widthInPixels, heightInPixels); const resizedImage = canvas.toDataURL('image/png'); const downloadLink = document.getElementById('download'); downloadLink.href = resizedImage; downloadLink.style.display = 'inline'; } img.src = event.target.result; } reader.readAsDataURL(file); } function getConversionFactor(units) { const dpi = 96; // Average DPI for screen resolution switch (units) { case 'cm': return dpi / 2.54; // Convert cm to inches then to pixels case 'in': return dpi; // Inches to pixels default: return 1; // Pixels } } ]]>

Subscribe to receive free email updates:

Related Posts :

0 Response to "Image resizer"

Post a Comment