Copy link to clipboard
Copied
Is it possible to obtain an array that contains all of the pixels in the active document's current composition at a given frame? By "array of pixels," I'm referring to an array that contains all of the color data associated with each pixel in the composition. By composition, I'm referring to whatever is currently visible in the composition view (with all effects applied to layers, all layer blending modes considered, etc.) For example, if my composition currently looks like this:
Then the pixels in my array should correspond to black, blue, and white pixels. The exact representation of the pixel is unimportant; whether RGB, Hex, integer, etc, anything is fine as long as it contains some kind of interpretable color data. The ordering in the array is also unimportant for my specific application. Can this be done inside an after effects script, and if so, how?
Copy link to clipboard
Copied
I don't want to disappoint you, but I don't think it's possible in AE (at least not efficiency-wise).
Any chance you can save your current frame to image and process it in PSD? Most likely you can achieve what you are after in Photoshop.
Copy link to clipboard
Copied
Actually, I suppose that would be possible. If I could export the frame as a PNG and then load in the image data to analyze somehow, that would work just as well. I'm not sure if there would be an easy way to do that inside with the Adobe Javascript scripts though, but it would be really easy to do in Python.
Do you know of any way to run an external Python script and have it interact back and forth between the adobe Javascript? I'm not sure this would be possible either, but if I absolutely had to do it with a Photoshop script I suppose that could be my last resort.
Copy link to clipboard
Copied
Extendscript can't access any pixel level image data. If you're comfortable in Python, there are plenty of libraries available to process images. It's not a perfect solution but if I would need to do this, I would process png images in python and output the resulting data to a text file to be used however you like. If you want, you can do the following in a simple extendscript:
- render to png in a pre-defined location (e.g. path to current aep file, create a subdirectory for the png files and render to that location).
- create a bat/python file from within extendscript and execute the appropriate file from within your script.
- your python script will create a data file which contains all color information for every pixel in the image.
This is not the sexiest solution but it might help you to get done what you need to get done. Using numpy or one of the many available python libraries, you can analyze this data set further if you want.
The SDK allows you to access pixel data but then you're into C++ and a lot of pain if you have no experience creating plugins for AE using the SDK. Probably not the route you're looking for but it's there for the brave 😉
Copy link to clipboard
Copied
Maybe you can try to use the color sampler method
color sampler using sampleImage expression method | Creative Cloud blog by Adobe
If you move it above the entire picture, maybe you'll be able to store the RGBA data.