I tried to draw this image to canvas. https://res.cloudinary.com/casestry-com/image/upload/casestry-studio/render/14PMT/p1/black/2500x3000/gloss_mask.png In my local I checked that the rgb color at (551, 1439) is (18, 255, 255) But when I get the color after drawing the image to canvas the color is changed to (9, 255, 255) Is there any way to get the same color after drawing to canvas?
Here's the fiddle: https://jsfiddle.net/badu3ze6/5/
async function getImage(url) {
const imageLoadPromise = new Promise((resolve) => {
const image = new Image();
image.crossOrigin = "Anonymous";
image.src = url;
image.onload = () => {
resolve(image);
};
});
return imageLoadPromise;
}
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
async function loadImage() {
const img = await getImage("https://res.cloudinary.com/casestry-com/image/upload/casestry-studio/render/14PMT/p1/black/2500x3000/gloss_mask.png");
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
const data = ctx.getImageData(551, 1439, 1, 1).data;
try{
console.log('read by canvas:', [data[0], data[1], data[2]])
} catch (e) {
console.log(e);
}
}
async function readByImageJs() {
let image = await IJS.Image.load("https://res.cloudinary.com/casestry-com/image/upload/casestry-studio/render/14PMT/p1/black/2500x3000/gloss_mask.png");
console.log('read by imagejs:', image.getPixelXY(551, 1439));
}
loadImage()
readByImageJs();