Need help with optimize script(like autocrop) and sampleimage
zipkiev Feb 24, 2014 2:45 PMHi guys, i working on script(something like autocrop script), i already done trimming precomp but this process to find rgb pixels is to slow(autocrop work insanity fast compared with my script), need your help with optimization
i creat precomp and then in loop sherch on it rgb....
code
there are a loop code with process of search rgb:
var xmin = myComp.width, xmax = 0, ymin = myComp.height, ymax = 0;
for(var y=1; y<=myComp.height; y++)
{
for(var x=1; x<=myComp.width; x++)
{
myControlNull.property("Transform").property("Position").setValue([x,y]); //send to AE expression x y coordinates
if(out_checker_one_zero.slider.value==1) //get back 1 if sampleimage find rgb
{
if (x < xmin) //checking for finding xmin
{
xmin = x;
}
if (x > xmax) //checking for finding xmax
{
xmax = x;
}
if (y < ymin) //checking for finding ymin
{
ymin = y;
}
if (y > ymax) //checking for finding ymax
{
ymax = y;
}
}
progBar1.value=x;
progBar2.value=y;
progressBar_palette.update();
//return progressBar_palette;
}
}
alert("maxX "+ xmax+ " minX " + xmin + " maxY " + ymax + " minY "+ ymin+"\r");
expression
//expression set on slider control
/*
sourceLayer = thisComp.layer("Black Solid 2_TRIM_SCRIPT");
area = [0.5,0.5];
NullsamplePoint=thisComp.layer("ZS_TRIM_COMP").transform.position;
color= sourceLayer.sampleImage(NullsamplePoint,area);
a=effect("Checker")("Slider");
if((parseInt(255*color[0]))>0)
{a=1;}
else if(parseInt(255*color[1])>0)
{a=1;}
else if(parseInt(255*color[2])>0)
{a=1;}
else if(parseInt(255*color[3])>0)
{a=1;}
else
{a=0;}*/
when i get this data i can crop my precomp to this x y coordinates, then i want render this comp and past image back to myComp and with replace my precomp (where search rgb )


