Closed variant-tech closed 2 years ago
Hi, I think this issue is related to the issue https://github.com/ibezkrovnyi/image-quantization/issues/95 which was fixed today, could you please try image-q@4.0.0
and let me know if your case is fixed too. Thanks
Still experiencing the same error in 4.0.0 Reproduction URL: https://codesandbox.io/s/88-reproduction-qensi
Thank you for Reproduction URL.
Atm decoding compressed images is non-goal for image-q project and need to be done with 3rd party library (e.g. pngjs or any other lib) or with help of browser.
The following line expects uncompressed array of 4 byte groups - one group of [r,g,b,a] per each pixel. So, it expects 270x310x4 bytes.
utils.PointContainer.fromBuffer(imageData, 270, 310)
It is useful when you already have uncompressed data, e.g. data comes from canvasContext2d.getImageData, etc.
slightly modified Reproduction URL
import axios from "axios"; import { applyPalette, utils } from "image-q"; (async () => { const { data } = await axios.get( "https://en.wikipedia.org/static/images/project-logos/enwiki-2x.png", { responseType: "arraybuffer" } );
const image = new Image(); image.onload = async () => { const pointContainer = utils.PointContainer.fromHTMLImageElement(image);
const palette = new utils.Palette(); // https://github.com/ibezkrovnyi/image-quantization/issues/48
palette.add(utils.Point.createByRGBA(0, 0, 0, 255)); // black
palette.add(utils.Point.createByRGBA(255, 255, 255, 255)); // white
const outputPointContainer = await applyPalette(pointContainer, palette, {
imageQuantization: "floyd-steinberg" // optional
});
console.log(outputPointContainer);
};
const base64 = btoa(
Array.from(new Uint8Array(data))
.map((b) => String.fromCharCode(b))
.join("")
);
image.src = data:image/png;base64,${base64}
;
// Original image document.body.appendChild(image); })();
Hi @ibezkrovnyi , confirming that issue is fixed on our end with 4.0.0. Thanks for the support!
Hi, i have an issue with buildPalette on the latest release of image-q. This is the code that I have, and buildConfig + applyConfig is just an object that contains options for vcolorDistanceFormula, colors, imageQuantization etc.
and then it returns an error that says the following
The var palette returns pretty much an empty Palette object, even though inPointContainer is valid and has rgba data. If you can look into the bug (in case it's a source code issue) that'd be great, happy to provide more info as well!