If I were doing this I would use PhotoShop scripting rather than actions whenever possible. To do the processes that you have those actions doing you could do the following:
set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
set listImages to list folder processFolder without invisibles
repeat with i from 1 to (length of listImages)
set thisimage to item i of listImages
set image_file_path to (processFolder & thisimage) as string
tell application "Adobe Photoshop CS2"
activate
open alias image_file_path
resize image current document width 800 resample method bicubic
adjust layer 1 of current document using inversion
save current document as JPEG in targetFolder
close current document
end tell
end repeat
This works on my computer and does not require any actions to be loaded.
To save out an action set there should be a pull down menu on the actions pallet, on a Mac it is a little “carrot” button on the upper right. If you click on that with the action set selected then there should be a save option that you can use.
I think ive found the problem: photoshop doesnt open the files, i tried to just open a file and that is what happend:
if the folder does not contain an image, nothing happens (as expected)
if the folder does contain an image, there are to possibilities:
if i use " open image_file_path" it tells me that an folder was expected and
if i use “open alias image_file_path” it tells me that the file “some object” has not been found.
I just copied and paste your scripts, so it cant be an typing failure so i think maybe the problem is, that
ive got an german version: maybe there are some differents?
ive got an old version: my Scripteditor is Version 2.1.1 (81) and my AppleScript 1.10.7 Do you use other Versions?
I’m using the same versions. Try the following script, if it does not work then post the event log. Basically what I have done is eliminated the building of the file name with a finder command to return a list of aliases in the folder that includes only JPEG files. Then I am stepping through that list item by item.
set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
tell application "Finder" to set listImages to (files of entire contents of processFolder whose file type is "JPEG" or name extension is "jpg") as alias list
repeat with thisimage in listImages
tell application "Adobe Photoshop CS2"
activate
open thisimage
resize image current document width 800 resample method bicubic
adjust layer 1 of current document using inversion
save current document as JPEG in targetFolder
close current document
end tell
end repeat
Again this is working on my computer. Hopefully using the finder command to get the list will eliminate any problems with opening the file.
It works!!!
Thanks a lot, there is only one small problem, but of another kind:
i dont know why but Photoshop takes about 2 mins for each picture and action so the script sends the failure that the program takes to long to act. If i just resize a picture in photoshop its done in less than a second. Is this “bicubic method” a special method with very high resolution?
if i take this step out of the script, it works (then with only the inversion) as fast as if i use Photoshop the “usual” way
And (maybe) the last question: Where can i find all the comands i can use on Photoshop like “adjust layer 1 of current document using inversion” so i dont have to ask vor every step i’ll do in the future?
Last things first, http://www.adobe.com/devnet/photoshop/sdk/PhotoshopScriptingGuide.pdf is a link to Adobe’s PDF, between that and opening the AppleScript dictionary for Photoshop (File>Open Dictionary, then select PhotoShop when the file menu comes up OR just drag the PhotoShop application icon to the Script Editor and the dictionary should open).
Now for the time for resizing the images, that has a lot to do with the size of the original image. Bicubic is the default method of interpolation for PhotoShop so it is nothing special and should not cause it to take longer than normal. If your original images are very large then it might take a while to scale them down to the 800 pixel width. On the images that I tested it with, all right around 800 pixels wide, it too less than 2 minutes to run through 3 images. I would check one of the original images and see how it compares with the time it takes to do it through the script. AppleScript does have a way around the script timing out for just this reason and that is using with timeout, the example below extends the amount of time that the script will wait before erroring out. Just change the number of seconds to a number that is acceptable to get the job done.
set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
tell application "Finder" to set listImages to (files of entire contents of processFolder whose file type is "JPEG" or name extension is "jpg") as alias list
repeat with thisimage in listImages
tell application "Adobe Photoshop CS2"
activate
with timeout of 500 seconds
open thisimage
resize image current document width 800 resample method bicubic
adjust layer 1 of current document using inversion
save current document as JPEG in targetFolder
close current document
end timeout
end tell
end repeat
Another, and more likely reason that it is taking a while is that your ruler units is set to something besides pixels, check on of the files. I will have a fix up in just a minute, I have to remember the proper preferences to reset.
set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
tell application "Finder" to set listImages to (files of entire contents of processFolder whose file type is "JPEG" or name extension is "jpg") as alias list
repeat with thisimage in listImages
tell application "Adobe Photoshop CS2"
activate
set ruler units of settings to pixel units
with timeout of 500 seconds
open thisimage
resize image current document width 800 resample method bicubic
adjust layer 1 of current document using inversion
save current document as JPEG in targetFolder
close current document
end timeout
end tell
end repeat
This is revised to ensure that you are working with pixels when resizing to 800, the resize command uses the ruler units so if that is set to centimeters then you will have a document that is 800 centimeters wide which will take a bit longer to do than resizing to 800 pixels wide.
I have a script that tells iPhoto to get the images that I CMD selected and open them in photoshop, then perform the same action for all the images. This have saved my a lot of time; however, is there any way to write a script that answers all the confirmation dialog boxes in photoshop when it is running the action (ie, Resize to 600 pixels?)? There are so many to answer and it would be great if I could just select the images, run the script then leave and come back and they are done. Sorry for the hijack, but I’m sure a lot of people could benefit from this, if it’s possible.
As I said earlier if you can do the function in AppleScript then why rely on actions? The script will probably give you less hassle with dialog boxes and is self contained, so that if you reset photoshop and no longer have the action loaded or run it on another computer then you don’t need to load the actions for the script to work. There are some things that you can’t do with a script and they can take a bit longer in some cases to write and trouble shoot but in the long run I think it works better to use AppleScript commands when they are available and only use actions when necessary. Resizing, changing the color mode, resampling, making overall adjustments are easy enough without actions, so why go to the extra trouble to work in two different automation systems to get things to work right?
As an accomplished scripter you will find your method more desirable and I can see the logic of some of your arguement, but for us poor applescript bodgers using actions is very useful. Firstly as a photographer you are at home creating actions in photoshop. You can edit the action easily and not have to worry about writing code, which if you fall into the bodge category can take you some time. Providing you set the action up correctly most tasks can be accomplished with the minimum of fuss.
I am a photographer and my entire workflow is scripted with a mixture of hard code and actions and Image Events. What started me off on my applescript journey was need to batch process images whilst incorporating database data. Something applescript is ideal for. It just felt right to use an action in CS2 rather than script it, Anything to make my life easier as I was trying to get my head around lists, moving images, renaming folders, talking to my database etc. I think a good way to start is to plan your workflow carefully and learn to record actions that will work when called from applescript. Once you start getting the feel of that then try hard coding. PLease don’t take this as criticism of your point of view, its of course not meant to be, but for photographers just starting out with scripting then using actions can be very useful and time efficient.
I don’t take that as criticism, and of course you should use what works for you and is fastest to set up becouse time is money. I have been working in AppleScript for the better part of 10 years, but use actions, styles, and other photoshop built in features as much as I do scripts, but then again as a designer I don’t do a lot of repetative tasks to a lot of different files.
mtorrance
I’m not sure where you set playback options for scripts. I don’t see anything in Script Editor to do this nor in PS. If there is a way to accelerate them further you might want to share with everyone where those options are.
This would be set in Photoshop using the Actions Palette. Select the action in question. Using the pop up menu in the top right corner of the actions palette select “Playback Options”. I think accelerated is the default but it’s worth checking.
Thank you Mark, I don’t think I have ever looked for that. This will accelerate to clarify this will speed up an action in photoshop if it was not previously selected and not the execution of an AppleScript or JavaScript. I’m pretty sure that the reason that the script was running slow for Schakal_No1 is that I failed to force the ruler measures to pixels and it was scaling it up to 800 on a different measurement system such as centameters or inches (though less likely since he said he is in Germany so is probably not using inches).
Just a couple of tips about actions and photoshop that you may or may not know. I have not the time to read the whole of this thread. You appear to be CS2 users so heres some options. Open bridge point it at a folder, from here you can make multiple file selections through sort order including manual sort. Then go tools/photoshop/batch and choose your action (this can also include inserted menu items such as fit image or conditional mode change for example) or go tools/photoshop/image processor (this is javascript) this contains an optional fit image plus run an action too. Your Bridge selection will now become the default source for files in both cases. Works very nicely and dammed handy too if you’d rather keep the scripting down to a minimum. BTW if you put equal measures in fit image then this is the maximum wether you image is portrait or landscape. Just an idea