Copy link to clipboard
Copied
I want to extract frame count using JSX script?
I have used following code. But it seems not sharp as expected (In case of decimal point of seconds it seems not good)
function getTimelineLength() {
var ref = new ActionReference();
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('duration'));
ref.putClass(stringIDToTypeID('timeline'));
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID('null'), ref);
var TC = executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);
TC = TC.getObjectValue(stringIDToTypeID('duration'));
var M = 0;
try { M = TC.getInteger(stringIDToTypeID('minutes')); } catch (e) { }
var S = 0;
try { S = TC.getInteger(stringIDToTypeID('seconds')); } catch (e) { }
var F = TC.getInteger(stringIDToTypeID('frame'));
var FR = TC.getInteger(stringIDToTypeID('frameRate'));
var A = new Array();
A.push([[M], [S], [F], [FR]]);
return A;
}
//option 1
var frameCount = timeLineInfo[0][2] ( But this returns "0" value with newly opened document)
//option 2
var timeLineInfo = getTimelineLength()
var frameCount = timeLineInfo[0][1] * timeLineInfo[0][3] ( This is not returns correct value with decimal value of seconds )
Anyone have a better solution?
var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('timeline'));
var ret = executeActionGet(r);
alert( ret.getInteger(stringIDToTypeID('frameCount')) );
//
Copy link to clipboard
Copied
var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('timeline'));
var ret = executeActionGet(r);
alert( ret.getInteger(stringIDToTypeID('frameCount')) );
//
Copy link to clipboard
Copied
And again. Thanks alot r-bin.
Copy link to clipboard
Copied
You also can get next properties of tilmeline
time
currentFrame
documentTimelineSettings
duration
enabled
frameCount
frameRate
hasMotion
workInTime
workOutTime
Copy link to clipboard
Copied
Thanks, r-bin. Very helpful.
Is there any documentation regarding these details?
I have tried using ScriptListener, but I could found a way to access and identify property details using output scripts.
Copy link to clipboard
Copied
This is my personal hacking experience. )
You can download Adobe Photoshop SDK and find in the file "PITerminology.h" the names of all the strings and chars for stringIDToTypeID or charIDToTypeID functions. Then you can write a script that checks the availability of the desired property for the object or class scrolling through all the strings. If successful, you can get the type of property and its data.
Sorry for the bad english.
Copy link to clipboard
Copied
Understood very well.
I observed several scripts, But still couldn't understand the pattern of coding.
If you have time, Could you please explain how did you construct below two sample scripts.
var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('timeline'));
var ret = executeActionGet(r);
alert( ret.getInteger(stringIDToTypeID('frameCount')) );
-------------------------------------------------------------------------
function next_key_frame()
{
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
d2.putEnumerated( stringIDToTypeID( "trackID" ), stringIDToTypeID( "stdTrackID" ), stringIDToTypeID( "sheetPositionTrack" ) );
d1.putObject( stringIDToTypeID( "trackID" ), stringIDToTypeID( "animationTrack" ), d2 );
executeAction( stringIDToTypeID( "nextKeyframe" ), d1, DialogModes.NO );
}
Copy link to clipboard
Copied
ok.
The second script I got using ScriptListener.
And the first one I got using this script to get a list of available properties.
Copy link to clipboard
Copied
WOW.
Thanks a lot, r-bin. Really appreciate.
Copy link to clipboard
Copied
))
There is an extended version of the script where you can see the values of simple property types or browse the properties of complex objects like OBJECT, LIST, REFERENCE, RAWTYPE, etc. to any depth.
But it only works on CS6 since on CC broke multi-column listboxies.
I can post link later if necessary.
Copy link to clipboard
Copied
Yes, Please post it r-bin. I will be very useful.
Copy link to clipboard
Copied
ok, keep it
Copy link to clipboard
Copied
Hello r-bin,
Unfortunately, the link doesn't work now. Could you please update it. I am really eager to know how did you get those properties of the timeline, what was the process. Thank you.
Copy link to clipboard
Copied
Probably that's the same that was in zip file: get_props
Copy link to clipboard
Copied
is this get_props the same as the function we see here?
below is that function, i dont see a zip or something called get_props
function get_adjustment_rawdata(id)
{
return get_prop_value("layer", id, "adjustment", 0, "legacyContentData");
}
Copy link to clipboard
Copied
Hopefully r-bin can edit his link to reupload original .zip, so we can know how it is 😉
Copy link to clipboard
Copied
This info was the gold for me, with this info i was able to make my global timeline scrubber work 🙂
Its works a bit like that one of After Effects, So in combination with the zoomed in time we get from Photoshop, this global one acts on the zoomed out version. Works on both Windows and OSX, is part of AnimDessin2 toolbar im doing updates for.
Its the timeline below those icons, i can make it show frames or timecode. When clicking it will set the timeindicator to the correct layer aka time in timeline. Sadly i dont know how i twould be able to get the correct layer below it. There is no code for. I tought perhaps use layer count. But we sometimes uses frames which are longer, so that would mess it up.
Its perhaps a bit hard to tell whats going on. But when you make an animation with a longer timeline and you are zoomed in on the timeline (lower panel), then scrolling left and right is a bit tedious. Therefor the global timeline is usefull. It will always show the full with of the timeline below those icons. So when you click, you see the bottom timeline jump to the correct part. The user only needs to select the frame below the indicator.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Note that this is still in development stage, most function works properly now. I need to push my latest work now i got the last parts of this new document dialog working. I also need to figure out the parts like zxp and perhaps got to UXP, which i really dont like.
PS in this post on the original repo, you can see the progress i made and work ive done on this panel. Its quite a lot, for me it was nice learning a bit more about panels. I wanted to expand the panel with more functionality. Added lots feats like multiple actions under 1 button, actions can be applied to multiple layers now. The timeline scrubber, an info panel and a video info panel. I added localization, still wip as my new document panels was still not finished. This is quite a monter to localize, need to figure out how can do this one.
https://github.com/sbaril/Photoshop-Animation/issues/8
Copy link to clipboard
Copied
All of these return 0 for me when I plug them into your original action reference code. Is this still working for anyone with the latest versions of photoshop in 2024 or am I doing something wrong?
(Incidentally, what I'm hoping to acheive is exporting the frame timing from one frame animation to import into a new one, i.e. [1s, 0.2s, 0.2s, 1s])
Copy link to clipboard
Copied
Please provide a sample file and the code you are using.
Copy link to clipboard
Copied
Apologies for delay, I must have missed the email.
@schroef You put me on the right track, thanks! I had to swap out "timeline" for "animationClass" and now it works:
var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('animationClass'));
var ret = executeActionGet(r);
alert( ret.getInteger(stringIDToTypeID('frameCount')) );
So that's working, but I'm still not seeing a way to get a frame animation frame's duration. The duration mentioned above seems to be for video clips maybe, as it throws an error when I try it with a frame animation.
Is there a way to get those? For instance, from the attached PSD, I'd like to in the end get `[1,0.2,0.2,0.2,0.2,1]`
Copy link to clipboard
Copied
This function return the t8melineframelength
// Paul Riggot
function getTimelineLength() {
var ref = new ActionReference();
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('duration'));
ref.putClass(stringIDToTypeID('timeline'));
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID('null'), ref);
var TC = executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);
TC = TC.getObjectValue(stringIDToTypeID('duration'));
var M = 0;
try {
M = TC.getInteger(stringIDToTypeID('minutes'));
} catch (e) {}
var S = 0;
try {
S = TC.getInteger(stringIDToTypeID('seconds'));
} catch (e) {}
var F = TC.getInteger(stringIDToTypeID('frame'));
var F = TC.getInteger(stringIDToTypeID('frame'));
var FR = TC.getInteger(stringIDToTypeID('frameRate'));
var A = new Array();
A.push([
[M],
[S],
[F],
[FR]
]);
return A;
}
Note that copy paste can break it. Simply test it with a. Alert()
Copy link to clipboard
Copied
Sorry as I reread it, I think you mean you want the time per frame. I'm not sure that's is possible. I have not found that that. I have used a combinations of codes to get the complete timeline duration as I need that for a custom timeline scrubber I made.
Copy link to clipboard
Copied
Ps there is also class to get duration as r-bin shower. I've never tried that, so perhaps that gets the duration per frame.
You will need a groot to jump to different frames though