Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


SampleImage() still broken through Extendscript

Participant ,
Mar 07, 2021 Mar 07, 2021

Copy link to clipboard

Copied

In continuation to this post: https://community.adobe.com/t5/after-effects/problem-with-sampleimage-in-after-effects-cc-2015-exten...

 

I am trying to harvest the result of a color control with a sampleImage() expression multiple times.

This works fine if I do it while the script is loading, so no visible UI yet and I manage to pull all samples into an array. If I try to run the exact same function after the window is up all results come back wrong, usually as a black pixel color.

 

I can see it happening in the After Effects UI as well, and as mentioned in the linked post above there has been a problem with harvesting a sampleImage() expression through a script, and it was claimed to be fixed a couple of versions ago but unfortunately no luck here.

 

Sampling pixels is such a powerful tool to enhance the script and have them making decisions contextually regarding actual content on the screen, it's like giving eyes to your scripts. It would benefit so many people to have this issue fixed, or even better, have a proper implementation of image sampling inside extendscript.

 

Thank you!

TOPICS
Error or problem, Expressions, Performance, Scripting

Views

76

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Mar 16, 2021 Mar 16, 2021
Hey!I still experienced issues. Not with your sample but with my script (Thank you for your sample by the way, but also notice the problem happened to me when the script has a panel, and when this process of sampling is done after the panel is up and running). However, while I don't know exactly why, the problem seem to happen when trying to harvest sampleImage by running a function that does all that (adds the color control etc...) through a click on an item with a click EventListener.Running t...

Likes

Translate

Translate
Adobe Community Professional ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Seems to be working to me in AE 2021, which version are you using?

(original script)

 

var myComp = app.project.activeItem;

var selectedLayer = myComp.selectedLayers[0];

var addColorControl = selectedLayer.Effects.addProperty("Color Control");

var expr = "sampleImage([50,50], [0.5,0.5], true, (time+0));";

addColorControl.property(1).expressionEnabled = true;

addColorControl.property(1).expression = expr;

var res = addColorControl(1).value;

alert(addColorControl(1).value);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

LATEST

Hey!

I still experienced issues. Not with your sample but with my script (Thank you for your sample by the way, but also notice the problem happened to me when the script has a panel, and when this process of sampling is done after the panel is up and running).

 

However, while I don't know exactly why, the problem seem to happen when trying to harvest sampleImage by running a function that does all that (adds the color control etc...) through a click on an item with a click EventListener.

Running the exact same function through a regular UI button using an "onClick" function works just fine!

 

I wanted to avoid adding a button by letting the user right-clicking the interface in order to resample, but at least using a button works.

However if someone at Adobe is interested in looking into this and maybe tracing down this issue it would be lovely and make the foundation of using sampleImage as a valid solution through a script even better.

 

Thanks for the help!

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines