Answers for "canvas js filter greyscale"

1

canvas js filter greyscale

const img = document.querySelector('img');
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');

img.onload = function() {
  canvas.width = img.width;
  canvas.height = img.height;
  ctx.filter = 'grayscale(1)';
  ctx.drawImage(img, 0, 0, img.width, img.height);
}
Posted by: Guest on August-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language