Indexing to a custom color table with a script?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

DSanburn

Indexing to a custom color table with a script?

Post by DSanburn »

Hi folks,

I'm trying to figure out if it is possible to script the conversion of an image to a specific color table. I know I can use an action for the process but I'd like a little more control over the process. I'd rather plug the file name into the script as opposed to rerecording the action every time I make a change to the color table (.act file).

I'm more familiar with applescript than Javascript but I'm not opposed to learning what I need to. If it were up to me I'd like to have a stand-alone program for this but all my research indicates a whole lot more programming knowledge would be required.

Anyway, I'd appreciate any help/comments you may have on this!
Andrew

Indexing to a custom color table with a script?

Post by Andrew »

Hiya DSanburn

What you want will not be difficult to do though I cannot immediately provide a complete solution (perhaps someone else can). From what you say there are two tasks:

1. Identify the files to perform the job on.

With CS the easiest approach (other than just working on the current active document) is to highlight the files in the file browser and use either a script or batch mode to open the files one at a time. If you are using CS then I can help script this, if you are using CS2 then it is slightly different and someone else can help.

2. Run the color table conversion on each file.

This is something I do not do myself so I am not familiar with it. However, if it can be recorded as an action, then you can use the Javascript Script Listener to record the action as javascript and then package it up in a JS function. You can then use scripting to specify the particular color table to use (or presumably to define the entire table) for that group of images.

Those are a couple of initial pointers, maybe if you identify what you want to do more exactly as well as your OS and version of PS we can help you more.

Andrew
Guest

Indexing to a custom color table with a script?

Post by Guest »

Thanks, the javascript listener did record a spiffy script that did index my image into the proper color table. Is there a way to incorporate that javascript easily into an applescript front end?

What I'd like to be able to do is load the .act file into a variable and then pass that variable as a parameter for the javascript. Something like this maybe?

-----
tell application "Adobe Photoshop 7.0"
activate
open myImage

set docRef to document 1

if (mode of docRef is not RGB) then
change mode docRef to RGB
end if

set colorTable to loadTable("colortable.act")
do script("indexImage", colorTable)

set myOptions to {class:PICT file save options, resolution:eight}
save document 1 in file myimage as PICT file with options myOptions
close document 1

end tell
-----

I suppose it all depends on how the javascript is written as to whether this is possible. I'm just not that familiar with calling a JS from an Applescript. Can you pass parameters?
Andrew

Indexing to a custom color table with a script?

Post by Andrew »

Grrrr, because I have changed PC's my version of the Adobe Photoshop CS Javascript Reference Guide is back to the Read Only one. Have a look at:

Photoshop CS\Scripting Guide\JavaScript Reference Guide.pdf

Utilities:Running Action Manager Code from Applescript

It should tell you what you need to know, if not ask again here.



Andrew
DSanburn

Indexing to a custom color table with a script?

Post by DSanburn »

I did a search through a few forums but haven't really found an answer. Is it possible to use multiple files via an #include or inherit statement in the javascript code?
Andrew

Indexing to a custom color table with a script?

Post by Andrew »

Yes, this is covered in the JavaScript Reference Guide.pdf, for example:

//@include 'ah-rawprocessor8.js';

includes the target script within the current script, you can include as many seperate target files as you like.

Andrew
DSanburn

Indexing to a custom color table with a script?

Post by DSanburn »

It looks like the //@include feature is only available for CS on up. I'm working on PS7 so it seems I'm going to have to just make some really big .js files.

Thanks for all your help!