I am working with images, I want when someone upload image, then image should convert into black and white image. My following code is doing that for me, but when I right click on image and downloading it then it downloading image as coloured image. Looks like my code only showing image in black and white not converting it's quality. Is their any way by which I can give user converted black and white image?
JsFiddle: https://jsfiddle.net/4kcyqbz5/
Code:
<html>
<body>
<form>
<p><label for="file" style="cursor: pointer;"><b>Upload Image</b></label></p>
<p><input type="file" accept="image/*" name="image" id="file" onchange="loadFile(event)"></p>
<p><img style="-webkit-filter: grayscale(100%); filter: grayscale(100%);" id="output" width="200" /></p><br>
</form>
<script>
var loadFile = function(event) {
var image = document.getElementById('output');
image.src = URL.createObjectURL(event.target.files[0]);
};
</script>
</body>
</html>