Extending Colorburst RIP automation capabilities.

We have the top of the line Colorburst RIP printing software, and it’s automation abilities are limited. It has Hot Folder (drag and drop) capability, but it does not resize images and cannot send the file elsewhere when done. This script is still in progress and changes would be very welcome. It occasionally hiccups and I haven’t found the kink(s) yet. My code is probably not very pretty either. I try.

Basically, when a file is dropped to a folder, this attached action opens the image in Image Events, resizes it to 5 inches max and saves in the Hot Folder to be printed. When completed successfully, the file is labeled purple - gray if unsuccessful.

property openTypes : {"PDF", "com.adobe.pdf", "BMP", "com.microsoft.bmp", "JPEG", "JPEG2", "jpg", "public.jpeg", ¬
	"PICT", "com.apple.pict", "PNG", "public.png", "PSD", "com.adobe.photoshop-image", "TIFF", "public.tiff"}

on open addedItems
	set theFolderName to "RIP Hot Folder"
	set thePath to ((path to desktop as text) & theFolderName & ":")
	if not pathExists(thePath) then
		display dialog "Files have not been copied. Could not find the path:" & return & return & thePath
		return
	end if
	runConversion(addedItems, thePath)
end open

on runConversion(theItems, thePath)
	repeat with anItem in theItems
		if my delayUntilDone(anItem) then
			tell application "Finder"
				set theType to file type of anItem
				set theExt to name extension of anItem
			end tell
			if (openTypes contains theType) or (openTypes contains theExt) then
				convertImage(anItem, thePath)
			else
				-- problem with the file, wrong type of file
				tell application "Finder" to set label index of alias (anItem as string) to 7 -- set label to GRAY!
			end if
		else
			-- problem with the delay function
			tell application "Finder" to set label index of alias (anItem as string) to 7 -- set label to GRAY!
		end if
	end repeat
end runConversion

on convertImage(theArt, thePath)
	--convert the image
	tell application "Finder"
		set saveExt to extension hidden of theArt
		set extension hidden of theArt to true
		set theNewArt to (thePath as text) & (displayed name of theArt) & ".tif"
		set extension hidden of theArt to saveExt
	end tell
	try
		tell application "Image Events"
			launch
			set imageFile to (open theArt)
			tell imageFile to set {resW, resH} to resolution
			set theRes to ((resW + resH) / 2)
			set theMax to 5 * (theRes) -- max image dimension in pixels
			scale imageFile to size theMax
			save imageFile as TIFF in theNewArt
		end tell
		-- mark purple to communicate that this file has been sent
		tell application "Finder" to set label index of alias (theArt as string) to 5 -- set label to PURPLE!
	on error errmsg
		-- problem saving the file to destination folder
		--display dialog errmsg
		tell application "Finder" to set label index of alias (theArt as string) to 7 -- set label to GRAY!
	end try
end convertImage

on pathExists(thePath) -- pathExists("path:to:folder: OR :file")
	try
		get thePath as alias
		return true
	on error
		return false
	end try
end pathExists

on delayUntilDone(theFile)
	set timeDelay to 10 -- the time to wait between size checks in seconds
	try
		set sizeThen to size of (info for alias (theFile as string)) --get initial size
		repeat
			delay timeDelay
			set sizeNow to size of (info for alias (theFile as string)) -- get new size
			if sizeNow - sizeThen is less than or equal to 0 then exit repeat
			set sizeThen to sizeNow
		end repeat
	on error
		return false
	end try
	return true
end delayUntilDone

I need help. I can’t figure out why this has changed its behavior. Months ago it was working fine, and now it is throwing an error here and not working:

try
       tell application "Image Events"
           launch
           set imageFile to (open theArt)
           tell imageFile to set {resW, resH} to resolution
           set theRes to ((resW + resH) / 2)
           set theMax to 5 * (theRes) -- max image dimension in pixels
           scale imageFile to size theMax
           save imageFile as TIFF in theNewArt
       end tell
       -- mark purple to communicate that this file has been sent
       tell application "Finder" to set label index of alias (theArt as string) to 5 -- set label to PURPLE!
   on error errmsg
       -- problem saving the file to destination folder
       display dialog errmsg
       tell application "Finder" to set label index of alias (theArt as string) to 7 -- set label to GRAY!
   end try

The error message says “cannot find item 1 of {}”. I tried to get a dialog out of every line, nothing throws one except the whole thing. What is going on!?

What the!!! Now it’s working again. I didn’t even change anything!

Hi,

two notes:

¢ It’s recommended always to close an image in Image Events after finishing with it
¢ why do you coerce the alias theArt to string and then back to alias in this line?

tell application "Finder" to set label index of alias (theArt as string) to 7