My code:
const fs = uxp.storage.localFileSystem;
const pluginFolder = await fs.getPluginFolder();
const theTemplate = await pluginFolder.getEntry("1.jpg");
let arr = await theTemplate.read({format: formats.binary});
const imageData = await imaging.createImageDataFromBuffer(
new Uint8Array(arr),
{
width: 501,
height: 350,
components: 3,
colorSpace: "RGB",
chunky: false
colorProfile: "Adobe RGB (1998)"
});
let layerInfo = await photoshop.core.executeAsModal(() => app.activeDocument.createLayer({name: 'newLayer'}))
let putPixelsOptions = {layerID: layerInfo.id, imageData: imageData}
await photoshop.core.executeAsModal(() => imaging.putPixels(putPixelsOptions))
result:
This happens with any image (OC Windows 10)
- I do not know what I am doing wrong. And once I did about the same code and everything worked. The width and height correspond to my image. I also don’t understand why all the parameters are required. Why uxp won’t immediately take the width and height of my image. And why can’t he determine the number of components per pixel?