Skip to main content
Inspiring
July 10, 2009
Answered

Some more guideance on whether to use Applescript/JS?

  • July 10, 2009
  • 2 replies
  • 3083 views

This is, in rough outline, what I want to do:

1. From within InDesign, extract the effective ppi of an image in the 'x' and 'y' directions.

2. In Photoshop, apply those numbers in a certain way to the image so that the effective ppi becomes 300 in Indesign. It's a simple formula that you apply to the Image Resolution.

3. Then I want to apply an Unsharp Mask with an edge mask to sharpen the image. This involves quite a number of simple steps.

I have written out the whole procedure in Pidgin Applescript (a combination of Applescript, BASIC and English) and it works perfectly. I have to do Step 1 manually, but for steps 2 & 3 I have generated an Action, with a modal control for step 2, which pauses and asks for input.

I want to know the best way to approach this task. Someone has told me (outside of these forums):

Your best bet will be to post in the scripting forum. It would need to be Applescript because I don't think Javascript can do multiple applications at once.

However, I'm not positive, but I don't think Open as Smart Object is available in the Photoshop CS3 Applescript dictionary. Maybe that's changed with CS4? Also, when I worked on the script dealing with layered Photoshop files, it created many seemingly insurmountable problems...

Michael Hale responded to a previous thread of mine (http://forums.adobe.com/thread/457438) suggesting JS instead of Applescript:

I would recommend that you use javascript for several reasons. First it is cross platform, second there seems to be more people on the forums using JS than AS, and last but not least in this case you can not work with the Action Manager API using AS. You would have to create and call JS functions from AS.

So, I am left with: Applescript because it can handle multiple applications at once, but JS because it can handle Actions. What is the best way to approach this task? AS or JS?

1. Extract some variables from a selected image in an open InDesign document.

2. Open that same image in Photoshop and change the Image Resolution (a calculation is involved)

3. Call up my Action to do the rest.

4. Ask if more sharpening is required, and the amount. Loop at this step until the answer is "No".

5. Save and close the image in Photoshop, and return to the selected image in InDesign to see the effect.

Any suggestions most appreciated.

This topic has been closed for replies.
Correct answer xbytor2
1. From within InDesign, extract the effective ppi of an image in the 'x' and 'y' directions.

The effective ppi of an image the ppi of the image as it's presented in ID as opposed to the actual ppi of the underlying image, correct? Just curious...

2. In Photoshop, apply those numbers in a certain way to the image so that the effective ppi becomes 300 in Indesign. It's a simple formula that you apply to the +Image Resolution+.

This could be done automatically if you scripted it instead of calling an action with a modal dialog.

What is the best way to approach this task? AS or JS?

Use both. Run AS to get the effective ppi, open the image in PS, and change the image rez. From AS, set up a loop (controlled with a 'More Sharpening?" prompt) that calls your action via JS (app.doAction("actionName", "actionSetName"). From AS, save and close the image, then return to ID to see the results.

You could do all of this in JS, but the solution would definitely be more complex primarily because you would have to use BridgeTalk to send messages back and forth between ID and PS.

-X

2 replies

xbytor2Correct answer
Inspiring
July 10, 2009
1. From within InDesign, extract the effective ppi of an image in the 'x' and 'y' directions.

The effective ppi of an image the ppi of the image as it's presented in ID as opposed to the actual ppi of the underlying image, correct? Just curious...

2. In Photoshop, apply those numbers in a certain way to the image so that the effective ppi becomes 300 in Indesign. It's a simple formula that you apply to the +Image Resolution+.

This could be done automatically if you scripted it instead of calling an action with a modal dialog.

What is the best way to approach this task? AS or JS?

Use both. Run AS to get the effective ppi, open the image in PS, and change the image rez. From AS, set up a loop (controlled with a 'More Sharpening?" prompt) that calls your action via JS (app.doAction("actionName", "actionSetName"). From AS, save and close the image, then return to ID to see the results.

You could do all of this in JS, but the solution would definitely be more complex primarily because you would have to use BridgeTalk to send messages back and forth between ID and PS.

-X

Guy BurnsAuthor
Inspiring
July 11, 2009

Thanks for the responses.

The effective ppi is the ppi as reported by InDesign. If the image has been scaled differently in the 'x' and 'y' directions, InDesign reports two: effective ppi = 270 x 350. Call them EPPIx and EPPIy. I want to choose the smallest.

SHARPEN is an Action I have generated which applies an Unsharp Mask with edge mask.

If I understand Xbytor2's response, this is what I should be doing in Applescript (not Javascript):

1. Extract the smallest effective ppi from InDesign, and using that number, change the image resolution in PS.

2. Call upon JS (from within AS) with something like: app.doAction ("SHARPEN", "MY ACTIONS")

OPTIONAL:

* Upon return from JS, ask: More sharpening? If "Yes" apply new amount to Unsharp Mask.

* Loop until "No"

3.  Upon return from JS, in Applescript: save, close, depart Photoshop, Enter InDesign.

4. End Applescript.

QUES: Do you think the optional steps are an unnecessary complication to the script? It is quite easy to simply open the USM window and apply new values myself and watch the effect.

Attached is a PDF with more details, including a complete Pidgin Applescript for the task. If it won't attach I'll upload to Mediafire.

Guy BurnsAuthor
Inspiring
July 11, 2009

Trying to attach.

MarkWalsh
Inspiring
July 10, 2009

My $.02

I program in both Applescript and Javascript, although I generally prefer using Javascript lately. Mostly because it's cross-platform and there are things that I feel it can do better (or at least, I can do better with Javascript). I started out with programming Applesript, and anything I have that works with multiple programs are using Applescript, mostly because at the time they were written, I didn't know Javascript. I believe you can target multiple applications with Javascript, although I have not done so. That, I believe, is not as simple to do as in Applescript, especially if you want to work with applications beyond the Adobe CS apps.

If your program will not need to be cross-platform, and will always run on a Mac, there's no problem with writing it in Applescript. You may not get as much response here for help as you would with Javascript, but there are people writing in Applescript here, so you should still be able to get help.