imagine photo automated workflow

Hi there everybody.

I got my hands on http://www.yvs.eu.com/imaginephoto.html and it’s scripting documentation which I found extremely well conceived and useful. Kudos to Kevin Meaney for his excellent work.

Unfortunately, development has stopped and Kevin seems to be fully tied up with other commitments, hence my request here in the forum.

I am using an automated worflow to create borders around images and would like to pass the results (an image file) to the following AppleScript:

on run
   set whiteColor to {65535, 65535, 65535}
   set blackColor to {0, 0, 0}
   set thisFile to choose file with prompt "Select an image to draw text on: "
   set file_info to (info for thisFile)
   set file_name to name of file_info
   -- to strip the extension from the name, uncomment the following two lines
   --set the_ext to name extension of file_info
   --set file_name to text 1 thru -((length of the_ext) + 2) of file_name
   tell application "iMagine Photo"
       set thisImporter to import graphic thisFile
       if the component error of thisImporter is not equal to 0 then
           close thisImporter
           return
       end if
       set theWidth to 800
       set theHeight to 600
       set thisDocument to make new window document with properties {dimensions:{theWidth, theHeight}, name:" Drawing Window "}
       set the drawing destination of thisImporter to thisDocument
       set the destination rectangle of thisImporter to {0, 0, theWidth, theHeight}
       draw thisImporter
       close thisImporter
       set textRecord to {class:standard text, font:"Times", font size:36, drawing text:file_name, start from:centre, start point:{theWidth div 2, theHeight div 2}, color:whiteColor, background color:blackColor, graphics mode:add pin, opcolor:{65535, 65535, 65535}, rotation:-90}
       set {textWidth, textHeight} to get text dimensions with properties textRecord
       set start point of textRecord to {theWidth - (textWidth div 2), theHeight div 2}
       tell thisDocument to create composition element with properties textRecord
   end tell
end run

which draws the file name on a border.

The above AppleScripts works manually but due to my limited experience, I don’t know how to automatically get the results coming from the workflow (an image file) into the script and finally save the file.

Can anybody help?

Thanking in advance

/Pieter

Model: iMac
AppleScript: 1.10.7
Browser: Firefox 2.0.0.1
Operating System: Mac OS X (10.4)

Hi Pieter,

saluti a Varese.
I remember driving around for an hour in Varese,
because I couldn’t find the turnoff to Ponte Tresa :lol:

I dont’ use iMagine Photo but select “Run AppleScript” in Automator,
put your code within the run handler, and add a repeat loop to process the single item like this

on run {input, parameters}
		set whiteColor to {65535, 65535, 65535}
		set blackColor to {0, 0, 0}
		repeat with thisFile in input
			-- set thisFile to choose file with prompt "Select an image to draw text on: "
			set file_info to (info for thisFile)
			set file_name to name of file_info
			--to strip the extension from the name, uncomment the following two lines
			--set the_ext to name extension of file_info
			--set file_name to text 1 thru -((length of the_ext) + 2) of file_name
			
	   	tell application "iMagine Photo"
	   	    set thisImporter to import graphic thisFile
	   	    if the component error of thisImporter is not equal to 0 then
	   	        close thisImporter
	   	        return
	   	    end if
	   	    set theWidth to 800
	   	    set theHeight to 600
	   	    set thisDocument to make new window document with properties {dimensions:{theWidth, theHeight}, name:" Drawing Window "}
	   	    set the drawing destination of thisImporter to thisDocument
	   	    set the destination rectangle of thisImporter to {0, 0, theWidth, theHeight}
	   	    draw thisImporter
	   	    close thisImporter
	   	    set textRecord to {class:standard text, font:"Times", font size:36, drawing text:file_name, start from:centre, start point:{theWidth div 2, theHeight div 2}, color:whiteColor, background color:blackColor, graphics mode:add pin, opcolor:{65535, 65535, 65535}, rotation:-90}
	   	    set {textWidth, textHeight} to get text dimensions with properties textRecord
	   	    set start point of textRecord to {theWidth - (textWidth div 2), theHeight div 2}
	   	    tell thisDocument to create composition element with properties textRecord
	   	end tell
	   end repeat
	   return input
	end run

Hello Stefan,

first thanks for the reply and the greetings. :slight_smile:

I have setup a flow to draw borders around a picture with iMagine photo and, after that, the script by you modified and finally a preview action to display the results.
It all works without hang-ups till the end but, I am not sure why, the Script does nothing at all… :slight_smile:

Apparently, it is not getting any values from the previous action.

Any further clues?

Would you like to test by yourself?

Imagine photo is freeware and the flow is extremely easy to set up.

Ciao

/Pieter