Image Resizer Tool
const inputImg = document.getElementById("input-img");
const inputWidth = document.getElementById("input-width");
const inputHeight = document.getElementById("input-height");
const resizeBtn = document.getElementById("resize-btn");
const outputImg = document.getElementById("output-img");
resizeBtn.addEventListener("click", () => {
if (inputImg.files && inputImg.files[0]) {
const reader = new FileReader();
reader.onload = () => {
const img = new Image();
img.onload = () => {
const canvas = document.createElement("canvas");
canvas.width = inputWidth.value;
canvas.height = inputHeight.value;
const ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, inputWidth.value, inputHeight
Comments
Post a Comment