The below problem occurs only in Chromium browsers but the same functionality works fine in Firefox: It seems that Chromium by default turns every load of an originally lossless image format (e.g. .png) into a lossy operation.
example:
let image = new Image;
image.onload = function() {
let canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
let ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
let imgData = ctx.getImageData(0, 0, image.width, image.height).data;
...
}.bind(this);
image.src = 'test.png';
In Chromium browsers the imgData returned here always seems to contain random
rounding errors as compared to the original data stored in the original .png file.
The magnitude of respective errors typically seem to be +/-1; rendering the respective
API quite useless.
Is there some workaround to make this kind of functionality work correctly (i.e. access the
original image data and not some corrupted version thereof) in garbage Chromium based browsers?