please help with a cropping script

Upload photoshop scripts, download photoshop scripts, discussion and support of photoshop scripts

Moderator: PS-Moderators

please help with a cropping script

Postby akhera » Thu Sep 17, 2009 5:36 am

Hi all,

can someone please help..the attached script is suppose to crop an image and save it as a new photoshop file in a particular folder.. now this use to work in CS3 but has stopped working in CS4... unfortunately I'm very new to scripting for adobe apps so any suggestion will be very welcomed.

thanks





set HomeSpot to (path to desktop) as Unicode text

tell application "Finder"

try
make new folder in HomeSpot with properties {name:"Cropped Images"}
end try

set TheFolder to folder "Cropped Images" as Unicode text

end tell

tell application "Adobe InDesign CS3.app"

tell document 1

tell selection

set {Fx1, Fy1, Fx2, Fy2} to «class gbnd»
set the_image to item 1 of every «class imag»
tell the_image
set {Ix1, Iy1, Ix2, Iy2} to «class gbnd»
set the_scale to «class phzs»
«event K2LKedto» of «class plnk»
end tell

end tell

end tell

end tell

set the_scale_factor to (the_scale / 100)

--return the_scale_factor

set {Cx1, Cy1, Cx2, Cy2} to {((Fx1 - Ix1) / the_scale_factor), ((Fy1 - Iy1) / the_scale_factor), ((Ix2 - Fx2) / the_scale_factor), ((Iy2 - Fy2) / the_scale_factor)} --as Unicode text

--set image_data to {Cx1, Cy1, Cx2, Cy2}

tell application "Adobe Photoshop CS3.app"

try
set SaveEPSOptions to {class:«class cSSP», «class pSEP»:true, «class EnCd»:«constant e290e264», «class HfTn»:false, «class ImIP»:false, «class PsCM»:false, «class PwTp»:«constant e250e254», «class Tsfr»:false, «class TpWh»:false, «class VcDt»:false}
set DisplaySaveEPSOptions to SaveEPSOptions as list as Unicode text
on error
display dialog "SaveEPSOptions Error"
end try

tell document 1

set the_height to «class Hght»
set the_width to «class Wdth»

set crop_data to {Cy1, Cx1, (the_width - Cy2), (the_height - Cx2)}

--set Jaosn to bounds of selection

«event 8BIMCrop» given «class Bnds»:crop_data


set Current_TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."

--try
set ThedocName to name as Unicode text
set DocName to text item 1 of ThedocName as Unicode text
--on error
-- display dialog "File Name Error"
--end try

set AppleScript's text item delimiters to Current_TID

set SaveTypes to "Saving " & ThedocName & " as a PhotoShop EPS with the following settings:" & return & return
set SaveNote to "PLEASE NOTE: If these settings are not suitable, you will need to see Jason to change them in the script coding."

--display dialog SaveTypes & "" & "• Embed Color Profile: true" & return & "• Encoding: Maximum Quality JPEG" & return & "• Halftone Screen: false" & return & "• Image interpolation: false" & return & "• PostScript Color Management: false" & return & "• Preview Type: eight bit Mac OS" & return & "• Transfer Function: false" & return & "• Transparent Whites: false" & return & "• Vector Data: false" & return & return & SaveNote with icon 1 giving up after 20

try
set SaveName to TheFolder & DocName & ".eps" as Unicode text
on error e
activate
«event PsCSclos» given «class savo»:no
display dialog "Save Name Error" & return & return & e
error number -128
end try
try
«event PsCSsave» with «class SaCp» given «class kfil»:SaveName, «class fltp»:«constant SvFme004», «class FmOp»:SaveEPSOptions, «class DcXt»:«constant e300e301»
on error e
activate
«event PsCSclos» given «class savo»:no
display dialog "Save Error" & return & return & e
error number -128
end try

«event PsCSclos» given «class savo»:no

end tell

end tell

--return image_data & return & crop_data & return & Jaosn
akhera
 
Posts: 2
Joined: Wed Sep 16, 2009 5:51 am

Postby larsen67 » Thu Sep 17, 2009 8:55 am

I don't have CS4 but this is an AppleScript and it targets CS3 as the app to use. Have you tried using this 'as is' buy just running it or have you opened it in 'Script Editor'
larsen67
 
Posts: 445
Joined: Sat Apr 25, 2009 3:01 pm
Location: Pickmere, Cheshire UK

Postby larsen67 » Thu Sep 17, 2009 9:18 am

OK I C&P this into Script Editor and it compiles for me. You may need to do the same at your end. This script uses InDesign & Photoshop versions CS3 if you have the script loaded in CS4 then you will need to edit it you can do this by double clicking on the script file itself or selecting it in InDesign's scripts pallet and choosing edit script from the fly out menu. When you try to compile the code if you don't have CS3 installed then you will be prompted to locate alternative app choose your CS4.
larsen67
 
Posts: 445
Joined: Sat Apr 25, 2009 3:01 pm
Location: Pickmere, Cheshire UK

Postby akhera » Thu Sep 24, 2009 1:24 am

hi guys, i am trying to run this script with PS CS4 and ID CS4, but it keeps comming up with the following error (see attached),

AppleScript Error!

Error number 8800
Attachments
Picture 4.zip
(34.04 KiB) Downloaded 298 times
akhera
 
Posts: 2
Joined: Wed Sep 16, 2009 5:51 am


Return to Photoshop Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron