Hi there everybody.
I got my hands on [url=iMagine Photo]http://www.yvs.eu.com/imaginephoto.html[/url] 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 would like to tailor the following script:
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: "
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:"Palatino", font size:36, drawing text:"This is the text to draw", 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
in order to get a prompt asking for the font type to use as well as the text to be written.
It must be trivial for an expert but my Applescript knowledge is limited… :rolleyes:
Could anybody please help me to modify this script?
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: "
display dialog "Please enter font type:" default answer "Chalkboard"
set the_font to text returned of result
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:the_font, font size:36, drawing text:" This is the text to draw ", 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
You can change the default text from Chalkboard to anything.
I have two more questions now, to complete my task: one simple, one difficult.
First I would like to use the image name as the text to be drawn, in other words, instead of the property
the script should retrieve the file name in a variable and draw the text using that.
iMagine Photo supports Automator Actions which I am using to add borders to an image.
I would also like to be able to pass that image document to above Script within automator.
If possible.
My final goal is getting Automator to draw borders around a picture and passing the picture to a script within that workflow that will draw that picture’s name on the border with a chosen font type.
Any further help to achieve this is really much appreciated
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: "
display dialog "Please enter font type:" default answer "Chalkboard"
set the_font to text returned of result
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:the_font, font size:36, drawing text:" This is the text to draw ", 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
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
display dialog "Please enter font type:" default answer "Chalkboard"
set the_font to text returned of result
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:the_font, 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