Knob rotation script for Photoshop
-
- KVRist
- 134 posts since 13 Apr, 2016
Hey guys,
After scouring the web yesterday for something to help me create a filmstrip for UI knob rotations, I looked into scripting Photoshop. Turns out Photoshop will execute a javascript file. Who knew?
I've attached the script I came up with as well as a sample Photoshop knob for an example. Hope this helps someone. I have to tell you that I'm so thankful to this forum for all the help and advice I've received. Consider this a tiny gift back.
Instructions:
- Open a file in Photoshop.
- Turn off all the layers you don't want as part of the knob (background, etc)
- Put everything you want rotated in one Layer Group (folder) and make sure that layer is selected.
- Leave that file as the frontmost window.
- In Photoshop go to File/Scripts/Browse to open knobRotate.jsx and it will run immediately
- It will ask for start & end angle (in degrees) and how many frames to render. Try the default values to test.
- It will work for a little while and create a new file, leaving the original (essentially) alone
- When it's done, it will pop up an alert window with info on the final frame sizes.
- That's it.
A few notes about the script:
- It's not bulletproof and does no error checking, so proceed with caution.
- The original Photoshop file is used during the process, but it's eventually left back to where it started.
- The real beauty of this is that when you use layer styles for shading and shadows, they stay correct as the knob gets rotated. Try the exampleKnob.psd that's attached to see what I mean.
Cheers gents!
After scouring the web yesterday for something to help me create a filmstrip for UI knob rotations, I looked into scripting Photoshop. Turns out Photoshop will execute a javascript file. Who knew?
I've attached the script I came up with as well as a sample Photoshop knob for an example. Hope this helps someone. I have to tell you that I'm so thankful to this forum for all the help and advice I've received. Consider this a tiny gift back.
Instructions:
- Open a file in Photoshop.
- Turn off all the layers you don't want as part of the knob (background, etc)
- Put everything you want rotated in one Layer Group (folder) and make sure that layer is selected.
- Leave that file as the frontmost window.
- In Photoshop go to File/Scripts/Browse to open knobRotate.jsx and it will run immediately
- It will ask for start & end angle (in degrees) and how many frames to render. Try the default values to test.
- It will work for a little while and create a new file, leaving the original (essentially) alone
- When it's done, it will pop up an alert window with info on the final frame sizes.
- That's it.
A few notes about the script:
- It's not bulletproof and does no error checking, so proceed with caution.
- The original Photoshop file is used during the process, but it's eventually left back to where it started.
- The real beauty of this is that when you use layer styles for shading and shadows, they stay correct as the knob gets rotated. Try the exampleKnob.psd that's attached to see what I mean.
Cheers gents!
You do not have the required permissions to view the files attached to this post.
- KVRist
- 77 posts since 23 Jul, 2013
Both vertical and horizontal worked fine here, Thank you very much! 
-
- KVRist
- 214 posts since 17 Jan, 2003
Hi! Thanks for the script!
As I test it I have the following issue with it.
In case I have some elements in the knob file that I want to be in the strip but I don't want them animated, those appear only in the first frame. I attached an example, you can see the layer named Marks (purple dots around the knob) which is intended to be in the strip but doesn't show up.
As I test it I have the following issue with it.
In case I have some elements in the knob file that I want to be in the strip but I don't want them animated, those appear only in the first frame. I attached an example, you can see the layer named Marks (purple dots around the knob) which is intended to be in the strip but doesn't show up.
You do not have the required permissions to view the files attached to this post.
"when you have nothing to say - shut up." -A friend of Luc Besson
-
- KVRist
- Topic Starter
- 134 posts since 13 Apr, 2016
Ah, forgot about that.
Until I can fix it, a workaround is:
Put the marks in a folder and turn everything else off. Run the script again, this time with a start & end angle of 0. It will create another file with none of the marks rotated that you can simply composite together with the original.
Hope that helps for now.
Until I can fix it, a workaround is:
Put the marks in a folder and turn everything else off. Run the script again, this time with a start & end angle of 0. It will create another file with none of the marks rotated that you can simply composite together with the original.
Hope that helps for now.
- KVRist
- 228 posts since 6 Jan, 2009 from UK
thanks a bunch @joshb, just tried it with PS CS6 (64bit) and works great.
I recommend making a copy of the image before working on it, in case you need to abort the process (eg. mistakes with parameters, ESC stops the script) and can't undo all the way back. of course that can also be done by users by wrapping it in an action.
EDIT: small tip, Photoshop (CS6 at least) can't save to PNG if the image width or height is larger than 32767 pels. It actually removes the PNG save option.
I tried to trick it by exporting my >40000 strip as a single Layer Comp (which has a PNG save option), it did actually save a PNG file but clipped it to 32767.
EDIT2: well even just below 32767 Photoshop still won't allow saving to PNG (I don't know where the threshold is). However this time the Scripts -> Layer Comps to Files trick works (just create a single Layer Comp first).
I recommend making a copy of the image before working on it, in case you need to abort the process (eg. mistakes with parameters, ESC stops the script) and can't undo all the way back. of course that can also be done by users by wrapping it in an action.
EDIT: small tip, Photoshop (CS6 at least) can't save to PNG if the image width or height is larger than 32767 pels. It actually removes the PNG save option.
I tried to trick it by exporting my >40000 strip as a single Layer Comp (which has a PNG save option), it did actually save a PNG file but clipped it to 32767.
EDIT2: well even just below 32767 Photoshop still won't allow saving to PNG (I don't know where the threshold is). However this time the Scripts -> Layer Comps to Files trick works (just create a single Layer Comp first).
Last edited by _gl on Fri Apr 22, 2022 11:44 am, edited 1 time in total.
- KVRAF
- 8493 posts since 12 Feb, 2006 from Helsinki, Finland
Something I want to mention (now that this got bumped) is that one might want to prefer vertical strips over horizontal ones at runtime for cache reasons, especially if drawing on the CPU. The issue here is not so much with accessing the image itself (it's probably unlikely to stay in caches anyway), but rather with horizontal strips (especially if the total width is a large power of two) there's a risk that even reading a single frame, each row maps to the same few associative sets in the caches, potentially trashing the whole set and therefore potentially evicting something else that would have been useful to keep. With vertical strips storing each frame as a continuous block of memory, this is much less of a problem.
- KVRist
- 228 posts since 6 Jan, 2009 from UK
I've adapted joshB's script so that you can have fixed components that don't rotate: https://desperatebeauty.com/_files/knob ... 20(dB).jsx
make sure that everything that rotates is in its own folder and that this is selected when you start the script (as before). any layers outside this folder will not be rotated but are now shown. also there's now minimal Undo stack activity.
make sure that everything that rotates is in its own folder and that this is selected when you start the script (as before). any layers outside this folder will not be rotated but are now shown. also there's now minimal Undo stack activity.
