Imaging, color management


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:, imageData: imageObj.imageData });

  } catch (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;
  } catch (e) {


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 !

I was getting black or negative type of image colors, try passing below options

let targetDocument = app.activeDocument;
let options = {
            "targetSize": { "height": 100 },
            "componentSize": 8,
            "applyAlpha": true,
            "colorProfile": "sRGB IEC61966-2.1",
            "colorSpace": 'RGB'

let pixels = await imaging.getPixels(options);