|
|
#1 |
|
AppleScripting Photoshop
Hello,
Basically I am trying to write a script that will work in conjunction with photoshop for work. The purpose of the script is to open up multiple files in photoshop off of a server using an applescript droplet. The files will all have different names and be in different locations on said server. Photoshop must then crop the files to three different pixel sizes and save them back on the server in specified folders, then Photoshop must covert original opened files to CMYK and save a jpeg and a tiff in another folder on the server. Also the files will be named "filename_rgb.jpg" and I want the CMYK files to be named "filename_cmyk.jpg" and "filename_cmyk.tif" here is my code so far: Code:
on open myFiles
tell application "Adobe Photoshop CS4"
activate
set myFiles to alias "Macintosh HD:Users:tomfinnane:Desktop:structure:2000x2000:Kav.jpg"
open myFiles as JPEG
set ruler units of settings to pixel units
set theDocument to current document
tell theDocument
resize image width 468 height 468 resolution 300 resample method bicubic
end tell
save theDocument in file "Macintosh HD:Users:tomfinnane:Desktop:structure:492x492" as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theDocument
set myFiles to alias "Macintosh HD:Users:tomfinnane:Desktop:structure:2000x2000:Kav.jpg"
open myFiles as JPEG
set ruler units of settings to pixel units
set theDocument to current document
tell theDocument
resize image width 200 height 200 resolution 300 resample method bicubic
end tell
save theDocument in file "Macintosh HD:Users:tomfinnane:Desktop:structure:200x200" as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theDocument
set myFiles to alias "Macintosh HD:Users:tomfinnane:Desktop:structure:2000x2000:Kav.jpg"
open myFiles as JPEG
set ruler units of settings to pixel units
set theDocument to current document
tell theDocument
resize image width 95 height 95 resolution 300 resample method bicubic
end tell
save theDocument in file "Macintosh HD:Users:tomfinnane:Desktop:structure:95x95" as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theDocument
set myFiles to alias "Macintosh HD:Users:tomfinnane:Desktop:structure:2000x2000:Kav.jpg"
open myFiles as JPEG
tell theDocument
convert to profile "Working CMYK" intent relative colorimetric with blackpoint compensation and dithering
end tell
save theDocument in file "Macintosh HD:Users:tomfinnane:Desktop:structure:CMYK" as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theDocument
set myFiles to alias "Macintosh HD:Users:tomfinnane:Desktop:structure:2000x2000:Kav.jpg"
open myFiles as JPEG
tell theDocument
convert to profile "Working CMYK" intent relative colorimetric with blackpoint compensation and dithering
end tell
set theName to name of current document
save theDocument in file "Macintosh HD:Users:tomfinnane:Desktop:structure:CMYK" as TIFF with options {class:TIFF save options, embed color profile:false}
end tell
end open
I hope there's someone out there who can help Thanks nazkav |
|
|
|
0
|
|
|
#2 |
|
I have to admit this one took a little while as I've never scripted Photoshop before. Also had to change a few things from your example especially the saving bits. The naming you would like wasn't exactly clear. Here's a working droplet script tested on Leopard with Photoshop CS2. Dropped files are resized 3 times and 2 cmyk files are created from the original file. The original file is left untouched. Replace CS2 with CS4 and change the paths. Unfortunately I'm on a standalone Mac so couldn't test the server side of your problem. If you want help with that you should post some more information eg what folders are shared on the server(What do you see in Finder-->Shared), a location of a file on the server, an example of a location where you want to put the resized files. Like : Shared Folder on server--> Folder structure --> the resized files go inside the structure folder. Screenshots would make things a lot easier.
Code:
-- This droplet processes files dropped onto the applet
on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
set this_item_string to this_item as string
set the_item_name to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of this_item_string
my resize_image(this_item, 468, 468, 300, "LeopardFirewire:Users:test:Desktop:" & the_item_name & "_rgb_492x492.jpg")
my resize_image(this_item, 200, 200, 300, "LeopardFirewire:Users:test:Desktop:" & the_item_name & "_rgb_200x200.jpg")
my resize_image(this_item, 95, 95, 300, "LeopardFirewire:Users:test:Desktop:" & the_item_name & "_rgb_95x95.jpg")
my CMYK_image_jpg(this_item, "LeopardFirewire:Users:test:Desktop:" & the_item_name & "_cmyk.jpg")
my CMYK_image_tif(this_item, "LeopardFirewire:Users:test:Desktop:" & the_item_name & "_cmyk.tif")
end repeat
end open
on resize_image(the_file, thewidth, theheight, theresolution, thefilename)
tell application "Adobe Photoshop CS2"
activate
open the_file as JPEG
set ruler units of settings to pixel units
set theDocument to current document
tell theDocument
resize image width thewidth height theheight resolution theresolution resample method bicubic
end tell
set thesavedoc to save theDocument in file thefilename as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close thesavedoc
end tell
end resize_image
on CMYK_image_jpg(the_file, thefilename)
tell application "Adobe Photoshop CS2"
activate
open the_file as JPEG
set theDocument to current document
tell theDocument
convert to profile "Working CMYK" intent relative colorimetric with blackpoint compensation and dithering
end tell
set thesavedoc to save theDocument in file thefilename as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close thesavedoc
end tell
end CMYK_image_jpg
on CMYK_image_tif(the_file, thefilename)
tell application "Adobe Photoshop CS2"
activate
open the_file as JPEG
set theDocument to current document
tell theDocument
convert to profile "Working CMYK" intent relative colorimetric with blackpoint compensation and dithering
end tell
set thesavedoc to save theDocument in file thefilename as TIFF with options {class:TIFF save options, embed color profile:false}
close thesavedoc
end tell
end CMYK_image_tif
Code:
--(path to desktop as text) is the same as "Macintosh HD:Users:tomfinnane:Desktop:" -- so this also works for constructing paths set the_desktop_path to (path to desktop as text) my CMYK_image_tif(this_item, the_desktop_path & the_item_name & "_cmyk.tif") Last edited by kryten2; Jun 3, 2012 at 08:23 AM. |
|
|
|
0
|
|
|
#3 |
|
Applescript Photoshop
Thank you for your in depth help with my problem.
I've been trying your script all day but unfortunately I keep getting an error when I drop the files on to the droplet The error is this: Can't get alias "Macintosh HD:Users:tomfinnane esktop:Kav_1.jpgThis is probably easily fixed but my Applescript knowledge doesn't extend that far. Any more help would be appreciated. By the way I'm trying to open 3 JPEG'S from my Desktop. Thanks nazkav |
|
|
|
0
|
|
|
#4 |
|
Strange shouldn't happen as the script worked for me. To debug this I'll need a couple of things.
1) Post the script you're using with the changes you've made(put it between the code tags!) 2) I'll attach another script for you to open in Script Editor and run after you made the necessary changes eg CS4 and paths. It's the same as the droplet with the exception that you have to choose a file manually. It will only process one file and you can comment out the second and third resize handlers and the cmyk handlers eg leave the first my resize_image as it is and put -- before the following four my statements. This will also speed things up. When the script errors it should highlight a section of the script where the error occured. Post a screenshot of the script window. Run the script again this time with the event log pane selected and post a screenshot of the event log. Or select all the text in the event log pane, put it in a text file and post that as attachment. |
|
|
|
0
|
|
|
#5 |
|
Applescript Photoshop
Hello,
I've tried your script and it all works fine so here is the script I'm using: Code:
on open theseItems
set theLocation to "Macintosh HD:Users:tomfinnane:Desktop"
tell application "Finder"
set archiveFolder to make new folder at theLocation with properties {name:"TEST"}
set firstJpgFolder to make new folder at archiveFolder with properties {name:"2000x2000"}
set secondJpgFolder to make new folder at archiveFolder with properties {name:"468x468"}
set thirdJpgFolder to make new folder at archiveFolder with properties {name:"200x200"}
set fourthJpgFolder to make new folder at archiveFolder with properties {name:"95x95"}
set cmykFolder to make new folder at archiveFolder with properties {name:"CMYK"}
end tell
repeat with i from 1 to the count of theseItems
set thisItem to item i of theseItems
set thisItemString to thisItem as string
set theItemName to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of thisItemString
my image(thisItem, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_rgb.jpg")
my resize_image(thisItem, 468, 468, 300, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_rgb.jpg")
my resize_image(thisItem, 200, 200, 300, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_rgb.jpg")
my resize_image(thisItem, 95, 95, 300, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_rgb.jpg")
my CMYK_image_jpg(thisItem, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_cmyk.jpg")
my CMYK_image_tif(thisItem, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_cmyk.tif")
end repeat
end open
on image(the_file, theFileName)
tell application "Adobe Photoshop CS4"
activate
open the_file as JPEG
set theDocument to current document
set theSaveDoc to save theDocument in file theFileName as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theSaveDoc
end tell
end image
on resize_image(the_file, theWidth, theHeight, theResolution, theFileName)
tell application "Adobe Photoshop CS4"
activate
open the_file as JPEG
set ruler units of settings to pixel units
set theDocument to current document
tell theDocument
resize image width theWidth height theHeight resolution theResolution resample method bicubic
end tell
set theSaveDoc to save theDocument in file theFileName as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theSaveDoc
end tell
end resize_image
on CMYK_image_jpg(the_file, theFileName)
tell application "Adobe Photoshop CS4"
activate
open the_file as JPEG
set theDocument to current document
tell theDocument
convert to profile "Working CMYK" intent relative colorimetric with blackpoint compensation and dithering
end tell
set theSaveDoc to save theDocument in file theFileName as JPEG with options {class:JPEG save options, embed color profile:false, quality:12}
close theSaveDoc
end tell
end CMYK_image_jpg
on CMYK_image_tif(the_file, theFileName)
tell application "Adobe Photoshop CS4"
activate
open the_file as JPEG
set theDocument to current document
tell theDocument
convert to profile "Working CMYK" intent relative colorimetric with blackpoint compensation and dithering
end tell
set theSaveDoc to save theDocument in file theFileName as TIFF with options {class:TIFF save options, embed color profile:false}
close theSaveDoc
end tell
end CMYK_image_tif
Thank you so much again for all your help nazkav |
|
|
|
0
|
|
|
#6 |
|
applescript Photoshop
Sorry just thought of something, I am trying to open multiple files on the droplet. Could that have something to do with it?
Thanks nazkav |
|
|
|
0
|
|
|
#7 | ||
|
Quote:
Quote:
I foresee problems with your tell Finder block. First time you drop something on the droplet the folders will be created, the second time you drop something it will error saying that the folders already exist. You can solve that by using something like this : Code:
set theLocation to "Macintosh HD:Users:tomfinnane:Desktop:"
tell application "Finder"
if not (exists folder "TEST" of folder theLocation) then
make new folder at theLocation with properties {name:"TEST"}
end if
set archiveFolder to "Macintosh HD:Users:tomfinnane:Desktop:TEST:"
if not (exists folder "2000x2000" of folder archiveFolder) then
set firstJpgFolder to make new folder at archiveFolder with properties {name:"2000x2000"}
end if
if not (exists folder "468x468" of folder archiveFolder) then
set secondJpgFolder to make new folder at archiveFolder with properties {name:"468x468"}
end if
if not (exists folder "200x200" of folder archiveFolder) then
set thirdJpgFolder to make new folder at archiveFolder with properties {name:"200x200"}
end if
if not (exists folder "95x95" of folder archiveFolder) then
set fourthJpgFolder to make new folder at archiveFolder with properties {name:"95x95"}
end if
if not (exists folder "CMYK" of folder archiveFolder) then
set cmykFolder to make new folder at archiveFolder with properties {name:"CMYK"}
end if
end tell
I'll try to post a zipped movie as an attachment of my original script in action. Last edited by kryten2; Jun 4, 2012 at 09:52 PM. |
|||
|
|
0
|
|
|
#8 |
|
Applescript Photoshop
Thank you again for your help I will try your solution and let you know. In answer to your questions, basically I tried your script (the one which prompts you to select a file) and it all worked fine. But I was wondering if the reason the droplet wasn't working was because I was dropping multiple files on to it. If your wondering why I'm using a droplet it is because that was the brief from work, they want a droplet on the desktop that is able to handle multiple files.
Thank you nazkav |
|
|
|
0
|
|
|
#9 | |
|
Quote:
Code:
--My code set the_item_name to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of this_item_string my resize_image(this_item, 468, 468, 300, "LeopardFirewire:Users:test:Desktop:" & the_item_name & "_rgb_492x492.jpg") --Your code set theItemName to do shell script "sed -E 's|:$||;s|.*:||;s|\\.[^.]*$||' <<< " & quoted form of thisItemString my resize_image(thisItem, 468, 468, 300, "Macintosh HD:Users:tomfinnane:Desktop:" & thisItemString & "_rgb.jpg") Last edited by kryten2; Jun 4, 2012 at 09:53 PM. |
||
|
|
0
|
|
|
#10 |
|
Applescript Photoshop
Hello again,
I've tried all that you told me to do and after massive headaches it finally works. So I would like to thank you for all your help in this matter you have been brilliant. Thank you a thousand times nazkav |
|
|
|
0
|
|
|
#11 |
|
No headaches for me at least not massive ones
Just a fun challenge. Thank you for the feedback.
|
|
|
|
0
|
|
|
#12 |
|
AppleScripting Photoshop
Kryten2,
I found your work on this applescript and wanted to give it a try. It gets me to the point of creating a TEST folder on the desktop with the correct subfolders, however, I get an error message that reads it "Can't get alias" with the path to the User folder and the Desktop with the folder name I am dragging onto the droplet. Any help or ideas that I can attempt would be great. Thanks in advance for any help. applepie375 |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 04:22 PM.






esktop:Kav_1.jpg
Just a fun challenge. Thank you for the feedback.
Linear Mode
