Wednesday, March 22, 2006

Siva's Photoshop Conditional Action

Hi all,

This is a tool I scripted for myself that I would like to share with all fellow Photoshopers. It allows you to execute your Actions based on Conditions. No programming needed. Just click and define your conditions.. Some examples of conditions are as follows :

i) If the image height is greater than its width, do Action X, or else do else Y
ii) If the image format is JPG / PSD / BMP do action...
iii) If the image file size is bigger than 300KB, do action....
iv) if the image IS/IS NOT of RGB, CMYK... etc
v) if image author is Siva, do action...
vi) if image exif contains Nikon D70s, do action ....
vii) if image name contains "paris", do action...
etc
etc

You can define lots of conditions that suit your workflow and needs. The list of image properties that can be 'conditioned' are as follows :
Format, height, width, file name , file size, resolution, color mode, color profile name, color profile type, bits per channel, pixel aspect ratio, author, caption, category, copyright type, copyright notice, country, exif, keywords, title..

Download Siva's Photoshop Conditional Action.

if the above link does not work, go to http://sivaratnam.googlepages.com and download it from there.

Steps to install :
1) Download the zip file above.
2) Unzip the 'Siva's Photoshop Conditional Action.jsx' file to a folder.
3) Copy the extracted file to your photoshop cs2 presets/script folder. in my case, the path is :
C:\Program Files\Adobe\Adobe Photoshop CS2\Presets\Scripts .
The path might be different on your computer.
4) In Photoshop, access the script by clicking File -> Scripts -> Siva's Photoshop Conditional Action. Screenshot

IMPORTANT - make sure you define a output folder for your action. The script itself does NOT change the original file. You have to explicitly record a step at the end of your action to save the file. Refer to this screenshot for example. Make sure you define the path ONLY, and not the file name in the save as step in your action.

The script works fine for Photoshop CS2 on Windows XP. I have not yet tested it on the Mac.
For FAQ and Help File please refer to the next post.

Siva
sivaratnam at gmail dott com

24 Comments:

Anonymous Anonymous said...

Absolutely fantastic!

Seems to work perfectly on a Mac too.

6:19 AM  
Anonymous Anonymous said...

This is just great! I was about to go find someone willing to make a script like that (since im not able myself, yet at leasat). So you really made my day, or days :)

5:23 PM  
Anonymous Anonymous said...

If you plan on scripting some more on it, a check box with include subfolders would work wonders :)
Anyway its great work. thanks for sharing

11:38 AM  
Anonymous Anonymous said...

Great script. Saved a lot of time but I did run into a problem. The script ran great when I compared height to width but when I tried to run an action if the height of an image was over 600 pixels it didn't work. Is the value really a pixel value or an inch value?

9:45 PM  
Anonymous Anonymous said...

I am getting the error message "gleft.toUpperCase is not a function"

Can this scripts variables be included/recored inside an action?

6:57 AM  
Blogger Siva said...

Guys,

Sorry as I could not reply earlier... been busy with work. First of all thanks to all who have emailed me and gave some constructive comments. I am trying to work on version 2 now, but am juggling between work and this.


[anonymous]
Thanks for your comment.
[/anonymous]

[Lasse]
Thanks for the comment. Noted your suggestion, will try to include it in version 2...
[\Lasse]

[anonymous]
Thanks for the compliments. The value is in pixels. I have emailed you the screenshot as it worked fine on my pc running XP and Photoshop CS2.
[\anonymous]

[anonymous]

"gleft.toUpperCase is not a function"

Can you please send me the screenshot of the condition screen for me to look at? I have never encountered this error, but will definitely look into it. I suspect that there might have been some non alphanumeric characters in the file name.. just guessing here... please send me the screenshot and the image file which generates the error. btw, this script only works with CS2.
[\anonymous]

my email is sivaratnam at gmail dot com

8:27 AM  
Anonymous Anonymous said...

Hm, the script doesn't work for me, when I try to include it in an action the script pops up every time when I run the action and I have to enter what I want it to do. That way I'm better of running two separate actions.. (I want it to rotate images in portrait orientation 90 degrees by the way).

5:56 AM  
Blogger Siva said...

Jan,

The script is NOT meant to be included in any actions. The script is an extremely simple one and not as sophisticated yet to be included in actions. Follow the steps below to use it :

1) Prepare your actions first. for example, in your case, you might just wanna record an action which does rotating the image 90 degrees and add a "Save As" step in that action. Assume we name the action Rotate90. An example screenshot is here http://sivaratnam.googlepages.com/rotate90.jpg

Note that the "Save As" step must ONLY specify the path and not include the filename (as highlighted by the red elipse)

2)Load the script and use the setting similar to this screenshot ... http://sivaratnam.googlepages.com/sample.jpg

It should work. Do let me know if it doesn't or if you run into any problems.

btw, you must use CS2 for this script to work.

cheers,

siva

9:23 AM  
Anonymous Anonymous said...

Thanks Siva, but that's what I figured out I think.

I guess I'll try using the script instead of the batch processor.

It would be great if something like this could be integrated in an action though (that way it could also be used with droplets), sofar I haven't found a solution for this. Would love to hear it if anybody knows something.

But it's a nice script anyway Siva, thumbs up :)

12:27 PM  
Anonymous Anonymous said...

great job.
but please let me know how can i customize it.

7:19 PM  
Blogger Unknown said...

Very useful script! I had the same issue as "John" had with the prompts to save images but I understand why it was happening and it makes sense. Maybe some sort of option in the dialog to override prompts to save could work?

12:17 PM  
Anonymous Anonymous said...

Great!
I had some problem to add the Save As step without file name, then in some way I succeeded (I still have to understand how), and now it works fine.
I got an error restarting the script after stopping it with 'esc', but restarting photoshop I solved the problem.

Thank you!

Alberto

8:02 AM  
Blogger Unknown said...

Have you finished version 2 which would include subfolders yet? That would be extremely useful otherwise the script is great!

Thanks.

9:09 PM  
Blogger Unknown said...

Hi! Thanks for a great script! Is it possible to change the "presets" of the script? I am using it to resize photos according to whether their orientation by using two separate actions, and every time I do it for a new folder I have to set the conditions again and again. It would be fantastic if the script "remembered" my settings so I would only have to click "run" every time. Is there a way to do this?

7:20 AM  
Anonymous Anonymous said...

This is awesome, so thanks very much.

I have a suggestion for a future release if you are planning one.

A test to see if the height/width is greater by percentage than the width/height would be great.

e.g. if height is more than 130% of the width do action A, otherwise do action B.

6:41 AM  
Anonymous Anonymous said...

thank you. I no longer have to sort out my landscape/portriat images and run seperate actions on them.

12:42 PM  
Blogger zokkan said...

this is the most useful content I've ever seen on internet (I mean it).

I really am excited about your script and I think this is more important than Adobe Photoshop itself :-)

I wish not only you have a good day, I wish you have the best life ever :-)

Thank you sooo much! Thank you! Thank you! Thank you!

11:15 AM  
Blogger Trae Regan said...

This worked on OSX 10.5 running Photoshop CS4 too - what a time saver - thank you so much!!

11:38 AM  
Blogger Stephan Möbius said...

Unfortunatly does not work in Photoshop CS5.1 anymore, the list of actions is empty then.

3:03 AM  
Anonymous Anonymous said...

6+ years after your original blog post... and still helping new people out!

Worked great for my resizing job on OSX 10.6.8, Photoshop CS2.

Thanks for supplying the functionality Adobe missed -- it's been a HUGE help!

(Also thanks to commenter 'John' for his 'docref.close' fix.)

12:41 PM  
Blogger Unknown said...

This is what I have been searching in many websites and I finally found it here. Amazing article. I am so impressed. Could never think of such a thing is possible with it...I think you have a great knowledge especially while dealings with such subjects.

clipping path

5:02 AM  
Blogger Stephen Marsh said...

Hi Siva, firstly thank you for the script, I have pointed many people to your site over the years.

Would there be any chance of adding support in your fantastic script to search for layers? Wishing for a conditional that can say skip over flattened files but perform an action on layered files (whether the layer is pixel based, text or adjustment layer).

It would also be good to have XMP support too, in addition to EXIF (probably easier said than done).

3:31 PM  
Anonymous Partha said...

Thanks Siva. it helped a lot. Its a timeless post.. always helpful. btw,is any other versionof this vailable wherein i can select save folder in the script?
aside to Jhn... thanks, you r inpput on doc close worked like a magic.

4:46 AM  
Blogger Balram Yadav said...

Nice blog!Thankyou for sharing very informative and creative contents. This content is very useful best way to extent the knowledge . Best coaching center of photoshop

12:32 AM  

Post a Comment

<< Home