Copy link to clipboard
Copied
There’s more on offer from this thread than a few ‘points’ or ‘question answered’. There are dollars as well.
I need a script to do a certain task in InDesign CS4 and Photoshop CS4 and I’m prepared to pay a reasonable amount. Full details of what I require can be downloaded as a PDF from:
http://www.megaupload.com/?d=QRQTL9QU
As part of the process, you will need to test the script on an InDesign document called TEST SCRIPT. The test document, plus a Photoshop Action that the script will be required to be call upon (SHARPEN), can be downloaded as a 88 MB zip file from:
http://www.megaupload.com/?d=MX3K667W
If after reading the PDF you think you are capable of writing such a script, please gmail me at gdburns, telling me when the script might be ready, how much it would cost, and how I would pay you.
1 Correct answer
I have NO issues with the links panel. All is updated in CS2 fine so it could be something in CS3/4.
You could replace the line in question with:
set Modified_Images to every link whose status is link out of date
repeat with This_Image in Modified_Images
update This_Image
end repeat
Although I think the out come will be the same.
I don't know if there is any access to workspaces in CS4 to show/hide the links panel? If the issue is just with the GUI not refreshing properly then you could use system
...Copy link to clipboard
Copied
This thread has come partly unstuck because Mark over at http://forums.adobe.com/message/2100470#2100470 wrote a script and posted it after I started this thread. He mustn't have seen this latest one.
However, the script is not working yet, so until it is I'm still after a working script for which I'm happy to pay.
Copy link to clipboard
Copied
Try to place Mark's script into the following folder:
Adobe InDesign CS4\Scripts\Scripts Panel\Version 3.0 Scripts
If it doesn't exist, create it – run the script from there (don't replace CS2 with CS4 in this case).
Copy link to clipboard
Copied
No workee! Comes back with "Where is CS2?"
I don't know how to put this without causing upset, because I know users of this forum are only trying to help this dumb cluck. But, whoever would like to get paid for writing me a script, please gmail me at gdburns. I'm completely useless with scripts. A total 100% imbecile when it comes to scripts. I want to buy a script as per my PDF, because discussing scripts and moving them in and out of folders is beyond me.
I'm off to the other thread to close that down (as far as I'm concerned), so that I can concentrate on this one.
Copy link to clipboard
Copied
Posted back in the wrong thread so duplicated here for you or others to continue with.
Guy, you error sounds to me like the user has a rectangle selected and NOT the image inside of a rectangle. The script is absolute bare bones with zero error trapping. A rectangle has NO ppi property to return. It was the first time I've even taken a look inside of the InDesign AppleScript dictionary. I mostly use QuarkXPress but have recently started with ID so Im NO great shakes with either the GUI or scripting. The code is there for anybody to use or repurpose. The reason behind changing both the resolution & the dimensions is so you get the required EPPI in your image file. Just changing the resolution would have no effect and would merely change the bounds of the linked image which you would then need to re-scale & re-position and when you've done that the EPPI would be back where you started.
effective resolution = actual resolution * scale factor
The way in which I thought you would want this is to calculate new resolution whilst maintaining actual image bounds for less user work.
Does that make sense? I only needed to calculate and change the height or width because 'Constrain Proportions' is default
Copy link to clipboard
Copied
Thanks Mark for the feedback. The script seems to work near perfectly, but I've yet to fully test it.
As I said, I'm pretty dopey when it comes to scripting, and you were right: I was selecting the image with the black pointer instead of the white one.
QUES 1
There's something I don't understand here. When I run through the process manually, and get to the change image resolution, I simply type in the new image resolution in Image > Image Size > Document Size > Resolution. I never touch anything else, and it works perfectly.
I just checked, and when I change the resolution, the Document Size doesn't change, but the Pixel Dimensions do. Which is exactly what I want. i.e the number of pixels changes, but the image dimensions (in inches) stays the same (otherwise, when linked to InDesign, the image will be the wrong size).
If I only need to change the resolution when I run through the process manually, why can't the script do the same? i.e just change resolution, and the pixels change in sympathy? Or doesn't scripting work that way?
In particular, your code says, in part:
resize image height (Image_Height * (300 / Resample))
Is that part necessary? Doesn't changing the resolution change the number of pixels automatically?
QUES 2
Your code says:
close with saving
But my Action (SHARPEN) ends with a save and a close. I assume I can safely remove "close with saving".
QUES 3
Lots of my images are behind others and I have to use Command-click to get to them, which doesn't work with the white pointer. i.e the contents are not selected. I have to go to Object > Select > Content. Is it possible to recode the start of the script so it does that automatically? i.e. always selects the contents of whatever is selected? No big deal if it's not possible. It would just slightly simplify matters.
Copy link to clipboard
Copied
Guy,
1. I have been back and checked and it appears that I can ignore re-calculating any of the dimensions just as long as a resample method is chosen. From a script point of view it could be left out but the result is the same image file bounds remain as were. Your replacement line could just be.
resize image resolution (Image_Res * (300 / Resample)) resample method bicubic smoother
2. add -- hyphen hyphen to the start of this line to comment out or just remove it.
3. You will get better advice in this forum on how to handle dealing with what you have selected in ID.
hope this helps.
Copy link to clipboard
Copied
Guy, this should be a bit nearer to what you require. Has a few checks that were not there before and will also allow you to select an images rectangle too. There are probably much better ways to do this but Im new & pushed for time…
tell application "Adobe InDesign CS2"
activate
tell active document
set Resample to ""
set This_Selection to get selection
try
if This_Selection ≠ {} then
if length of This_Selection ≠ 1 then
display dialog "You have more than 1 item seleted!!!" giving up after 2
else
if class of item 1 of This_Selection as text is "image" then
set This_Image to item 1 of This_Selection
end if
if class of item 1 of This_Selection as text is "rectangle" then
set This_Image to image 1 of item 1 of This_Selection
end if
set EPPI to effective ppi of item 1 of This_Image
set {Hoz_PPI, Vert_PPI} to {item 1 of EPPI, item 2 of EPPI}
if Hoz_PPI ≤ Vert_PPI then
set Resample to Hoz_PPI
else
set Resample to Vert_PPI
end if
set Image_Path to file path of item link of (item 1 of This_Image) as alias
end if
else
display dialog "You have 0 items seleted!!!" giving up after 2
end if
if Resample ≠ "" then
my Resample_Image(Resample, Image_Path)
update item link of (item 1 of This_Image)
end if
on error
display dialog "This rectange contain NO image!!!" giving up after 2
end try
end tell
end tell
--
on Resample_Image(Resample, Image_Path)
tell application "Adobe Photoshop CS2"
set display dialogs to never
set User_Rulers to ruler units of settings
set ruler units of settings to pixel units
activate
open Image_Path
set ID_Image to the current document
tell ID_Image
set Image_Res to resolution
if Resample < 270 then
resize image resolution (Image_Res * (300 / Resample)) resample method bicubic smoother
end if
if Resample > 330 then
resize image resolution (Image_Res * (300 / Resample)) resample method bicubic sharper
end if
-- do action "Action Name String" from "Action Set Name String"
end tell
set ruler units of settings to User_Rulers
end tell
end Resample_Image
Copy link to clipboard
Copied
Mark, your new version appears to work a treat, though I will be extensively testing it on a wide variety of images before I let it loose in my book.
Two minor points:
1. The image, after processing, is updated in InDesign, but the Links panel reports that it is not updated -- it has a little yellow triangle next to the image. It would appear that although InDesign did update the image, that updated info is not remembered by InDesign. Sounds like an InDesign problem.
2. At the end of the script I am still in PS. No problem whatsoever. I may change SHARPEN so I do stay in PS with the image open so that I can edit the image. But most of the time I would like to return to InDesign. I've tried putting:
tell application "Adobe InDesign CS4"
activate
end tell
or simply the command activate, before and after 'update link'; before the subroutine listing; at the end of the entire script; but I am always left with an error message. How do you make InDesign active at the end?
Finally, this Red LIon, is that in Knutsford? How often do you visit? Since you won't accept payment (I think you're underselling your skills), I'll contact the pub and arrange for a voucher for half a dozen pints, if that's possible. Take your mates down there and toast the 'script luddite' Tasmanian you've been helping.
Copy link to clipboard
Copied
Guy, as the script from a Photoshop point of view is no longer dealing with measurements you can get rid of changing the ruler settings. (using pixels is due to a bug in PS) In CS2 I do NOT get the yellow triangle warning the image is updated just fine. I do have the save command in my test script and NOT in the action may be you could try this. (not sure if the script is trying to do something before the action completes it's thing) How are you running the script? Is it loaded in the presets then you select an image or image containing box then double click to run the script? Here is what was last working just fine here…
tell application "Adobe InDesign CS2"
activate
tell active document
set Resample to ""
set This_Selection to get selection
try
if This_Selection ≠ {} then
if length of This_Selection ≠ 1 then
display dialog "You have more than 1 item seleted!!!" giving up after 2
else
if class of item 1 of This_Selection as text is "image" then
set This_Image to item 1 of This_Selection
end if
if class of item 1 of This_Selection as text is "rectangle" then
set This_Image to image 1 of item 1 of This_Selection
end if
set EPPI to effective ppi of item 1 of This_Image
set {Hoz_PPI, Vert_PPI} to {item 1 of EPPI, item 2 of EPPI}
if Hoz_PPI ≤ Vert_PPI then
set Resample to Hoz_PPI
else
set Resample to Vert_PPI
end if
set Image_Path to file path of item link of (item 1 of This_Image) as alias
end if
else
display dialog "You have 0 items seleted!!!" giving up after 2
end if
if Resample ≠ "" then
my Resample_Image(Resample, Image_Path)
activate
-- delay 4
update item link of (item 1 of This_Image)
end if
on error
display dialog "This rectange contain NO image!!!" giving up after 2
end try
end tell
end tell
--
on Resample_Image(Resample, Image_Path)
tell application "Adobe Photoshop CS2"
activate
set display dialogs to never
open Image_Path
set ID_Image to the current document
tell ID_Image
set Image_Res to resolution
if Resample < 270 then
resize image resolution (Image_Res * (300 / Resample)) resample method bicubic smoother
end if
if Resample > 330 then
resize image resolution (Image_Res * (300 / Resample)) resample method bicubic sharper
end if
-- do action "Action Name String" from "Action Set Name String"
close with saving
end tell
end tell
end Resample_Image
Copy link to clipboard
Copied
Mark, thanks for the updated script. It fixed the "not opening InDesign at the end" problem, but the un-updated link still remains in CS4. That's really not worth worrying about though.
I have removed save and close from the Action, and let the script do that (as per your suggestion). The script is located in a folder so that when I go to Window > Automation > Scripts the script appears. This is what happens when I double-click the script:
1. At the end of the process, InDesign is activated.
2. The image 'blinks' for a second or so (if the file size is large) while it is updated.
3. The image appears sharper, but the yellow rectangle appears in the Links panel.
4. If I zoom in, the image pixellates as if the image has NOT been updated.
5. If I zoom out to the original size, the image again appears sharpened.
6. If I update the link manually, everything is fine.
It would appear that InDesign is only updating the image that appears on the screen. Funny thing. There must be something not quite right about how CS4 interprets this line of the script:
update item link of (item 1 of This_Image)
Maybe CS4 is only updating the preview image that is contained within the document, and not updating and applying the altered link. Is that possible?Can the link be updated, but not applied?
Could the script force the issue by mimicking the manual process? In Pidgin Applescript it would be something like:
SELECT AND CLICK ON: Window > Links > Update Link
Copy link to clipboard
Copied
I remember there is a problem in CS2/3 with updating links by script: a link is actually updated, but Links panel shows that it is modified. If you hide and show the Links panel, then it shows the link correctly. May be the same problem still remains in CS4.
Try to add a line at the end of the script that updates all modified links.
Kasyan
Copy link to clipboard
Copied
I have NO issues with the links panel. All is updated in CS2 fine so it could be something in CS3/4.
You could replace the line in question with:
set Modified_Images to every link whose status is link out of date
repeat with This_Image in Modified_Images
update This_Image
end repeat
Although I think the out come will be the same.
I don't know if there is any access to workspaces in CS4 to show/hide the links panel? If the issue is just with the GUI not refreshing properly then you could use system events to hide then show the links panel. By keystrokes d+comm+shift an ugly solution that would go like this:
tell application "Adobe InDesign CS2"
activate
my Hide_Show()
end tell
--
on Hide_Show()
tell application "System Events"
tell process "Adobe InDesign CS2"
keystroke "D" using {command down, shift down} -- Hide Links pallet
delay 0.5
keystroke "D" using {command down, shift down} -- Show Links pallet
end tell
end tell
end Hide_Show
You need to change system prefs to be able to do this BTW
Copy link to clipboard
Copied
Mark, I think I'll settle for the script that leaves the link updated. Replacing the "update" line in your script with your newer version does all sorts of weird things. Computers amaze me how they can be so inventive.
1. I replaced the original "update" line with your newer version, and saved the script under a new name.
2. Clicked on the first image in my Test document and ran the script.
3. The second image was selected (not the first), it sharpened, and appeared to update.
4. Tried again -- the image that was processed was always the one after the selected image.
5. Other errors crept in: "no image selected"; resampling but not sharpening; not updating.
Amazing. You wouldn't believe the numerous permutations of errors that cropped up. So back I went and copied your script from this site, pasted it into a blank script and away it went.
Maybe my computer was just playing games with me. Anyway, I'm sticking with the script that doesn't update. It works quite well.
I'm going to put all this into a PDF soon, explaining what has been created here, and then I'll start a new thread over in the InDesign forum introducing this great new script. Is it okay if I include your script (acknowledged of course) and make it available via Mediafire to whoever wants it? I'll make everything up into a zip package: script, SHARPEN, InDesign test file, and an explanatory PDF.
Copy link to clipboard
Copied
Back again. I thought I'd better try rebooting OSX, tossing all scripts in Script Panel, reloading your script from scratch and including the new version of "update". When I did that and tried it on my Test file, the update worked.
I'll give the script a thorough workout tomorrow and let you know how it goes in CS4.
Copy link to clipboard
Copied
Glad you got something workable at least…
Credit 'anony mouse' don't be mentioning me… ha ha
Copy link to clipboard
Copied
Righto Mark, if you want another scripting challenge, sink your teeth into this one:
http://forums.adobe.com/thread/465884

