Layer opacity and layer fillOpacity no longer expressed in percent--can someone confirm?

This is strange.

const activeLayer = batchPlay([{ "_obj": "get", "_target":{ "_ref": "layer", "_enum": "ordinal", "_value": "targetEnum" } }], { synchronousExecution: true })

console.log(`opacity = ${activeLayer[0].opacity}`)
console.log(`fillOpacity = ${activeLayer[0].fillOpacity}`)

outputs the following at the console:

opacity = 255
fillOpacity = 255

This is for a layer with both opacity and fillOpacity set at 100%.

The documentation for these two layer properties states:

fillOpacity number R W 23.0 The fill opacity of the layer, in percentage.
opacity number R W 22.5 The master opacity of the layer, in percent.

I get the same results on both the current product version of Ps (24.4.1) and Ps Beta (24.6.0).

Alchemist shows the same results as does retrieving these numbers via batchPlay.

Are other people seeing this also? Shouldn’t the output match the percentage in the respective boxes in Photoshop?

That is how it works internally in Photoshop. BatchPlay is low-level control closer to how it works internally. DOM is here to abstract it closer to the experience from the user’s point of view… similar to UI.

1 Like

That’s because the activeLayer you are looking at is the batchPlay-derived data (ActionDescriptor). If you want to see the DOM data, you need to access the object for the DOM.

const photoshop = require('photoshop') ;
const { batchPlay } = photoshop.action ;
const { Layer } = ;

const main = async () => {
  const activeLayerDesc = (await batchPlay([{ "_obj": "get", "_target":{ "_ref": "layer", "_enum": "ordinal", "_value": "targetEnum" } }], { synchronousExecution: true }))[0] ;
  console.log(`ActionDescriptor.opacity = ${activeLayerDesc.opacity}`) ;
  // --> ActionDescriptor.opacity = 255
  console.log(`ActionDescriptor.fillOpacity = ${activeLayerDesc.fillOpacity}`) ;
  // --> ActionDescriptor.fillOpacity = 255
  const activeLayer = new Layer(activeLayerDesc.layerID, ;
  console.log(`DOM.opacity = ${activeLayer.opacity}`) ;
  // --> DOM.opacity = 100
  console.log(`DOM.fillOpacity = ${activeLayer.fillOpacity}`) ;
  // --> DOM.fillOpacity = 100
} ;

Ah, batchPlay and DOM APIs don’t always mix. Didn’t know that. Thought they were just different ways to do the same thing. Thanks for the clarification.

1 Like