Hello!
I’m trying some different things with Imaging API : I can read/write correctly directly in the document (getpixels / putpixels) with correct colors… But when trying to display the image in the panel, I can’t display correct colors.
Even the sample uxp plugin named “imaging-test” has a thumbnail picture with wrong colors.
const imaging = require('photoshop').imaging;
const executeAsModal = require('photoshop').core.executeAsModal;
const app = require('photoshop').app;
async function getPixel() {
let imageObj;
let layer;
try {
imageObj = await executeAsModal(async () => {
return await imaging.getPixels({});
});
await executeAsModal(async () => {
layer = await app.activeDocument.createLayer();
await imaging.putPixels({ layerID: layer.id, imageData: imageObj.imageData });
});
} catch (e) {
console.log(e);
}
try {
let imageBlob = new ImageBlob(await imageObj.imageData.getData(), imageObj.imageData);
const url = URL.createObjectURL(imageBlob);
const imageElement = document.getElementById("image");
imageElement.src = url;
URL.revokeObjectURL(url);
} catch (e) {
console.log(e);
}
imageObj.dispose();
}
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("pixel-btn").addEventListener("click", getPixel);
});
I tried to change the initial image with different space colors / formats, but there is always the same issue.
What’s the best way to display the current document “visible pixels” in a picture into the panel ?
Thank you !