Image Events needs a GUI
Image Events needs a GUI
- Subject: Image Events needs a GUI
- From: James Downie <email@hidden>
- Date: Mon, 11 Apr 2011 12:08:22 +1000
The included Applescript converts PDF files to a set of different resolution PNG files. It works great, except that when I try to run it over an SSH session (not in Terminal on the host GUI) I get...
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
I think i'd have this problem if I was running my applescript at set intervals with launchd. It's probably the part where I tell "Image Events" to launch.
Any advise?
on splitText(delimiter, someText)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set output to text items of someText
set AppleScript's text item delimiters to prevTIDs
return output
end splitText
on run argv
set pdfFileName to item 1 of argv
set pwd to do shell script "pwd"
set pdfFileNameParts to splitText(".", pdfFileName)
set basename to item 1 of pdfFileNameParts
set baseNameParts to splitText("-", basename)
set order_id to item 2 of baseNameParts
set sourceImage to (POSIX file (pwd & "/wip/" & pdfFileName)) as alias
tell application "Image Events"
launch
set fObj to open sourceImage
tell fObj
set resolutions to {1024, 800, 320, 100}
repeat with resolution in resolutions
set destinationImage to (pwd & "/converted/" & order_id & "-" & resolution & ".png")
scale to size resolution
save in destinationImage as PNG
end repeat
end tell
end tell
return sourceImage
end run
--
James Downie
0408 349 066
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden