View Full Version : Scripting - Rotate layer & save incrementally
08 August 2007, 10:07 AM
totally new to photoshop scripting and need to work out how to script this problem to save me some time.
I have a dial and a needle, i need to rotate the needle on a set anchor point (for it to rotate naturally) through 260 degrees, on every 2.61 degrees I need to save out the image as a transparent gif and increment the file name, i.e needle_0 needle_1 etc. This is to give me 100 positions for the needle to point from 0 on the dial to 100.
whats the best way to do this?
Thanks in advance
PS dont recommend me to ps-scripting forums as i registered there last week and never been validated :sad:
08 August 2007, 06:02 PM
PS dont recommend me to ps-scripting forums as i registered there last week and never been validated
Then you need to contact them, the E-mail address is on their main page. If they're a problem and you don't contact them, then they'll never know, right?
08 August 2007, 06:51 AM
It can be done, I'd help out but I don't know the syntax err how the code functions to be able to write the script for you, I should probably just look at what I can do in it, outside thought, ANYWAY, this would be extremely easy to do in a compositing program like after effects.
Just move the layer, key frame it and then export the movie to gif sequence, saving transparency as well, just make sure it's rendering as rgb + alpha.
Pretty sure you can do gif sequences, if not you can batch save from png to gif in photoshop with actions.
08 August 2007, 11:08 AM
I'd do it the AE way as well, but if you're looking for scripting, here's a solution (jscript):
strtR = app.preferences.rulerUnits;
strtD = app.displayDialogs;
app.preferences.rulerUnits = Units.PIXELS;
app.displayDialogs = DialogModes.NO;
var mydoc = app.activeDocument;
var curPath = app.activeDocument.path;
var saveOps = GIFSaveOptions;
saveOps.transparency = true;
var rotNumb = 0;
var saveNamePrefix = "arrow";
var histoS = mydoc.activeHistoryState;
var saveFile = new File(curPath+"/"+saveNamePrefix+"_"+rotNumb+".gif");
mydoc.activeHistoryState = histoS;
rotNumb += 1;
app.preferences.rulerUnits = strtR;
app.displayDialogs = strtD;
Only rotates the toplayer, from 0 to 260 with steps of 2.61, change it to whatever you need. Read the ps scripting references for more options (such as gif save options)
You need to have a document and save that document, as the created files will place themselves in that same folder.
As far as I know (I use CS 1) you cannot change the rotation anchor point of your layer but to the following: topleft, topcenter; topright, middlecenter etc... no custom array. I'd love to be proved wrong. In the script above I used an arrow pointing up, worked well I guess.
08 August 2007, 03:05 PM
oh and http://www.ps-scripts.com/bb/viewtopic.php?t=1327
08 August 2007, 03:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.