Re: add name/date to picture
Re: add name/date to picture
- Subject: Re: add name/date to picture
- From: Kevin Meaney <email@hidden>
- Date: Thu, 10 Mar 2005 21:19:38 +0000
A free alternative to Graphic Converter, to do the same thing faster.
iMagine Photo can also draw text onto images, plus it can draw text with any colour onto a background of any colour or with a transparent background.
iMagine Photo is a similar tool to Apple's "Image Events" but with a much larger range of functionality and is free.
I have included a script for iMagine Photo below. It is slightly more complicated, but what iMagine Photo can do is tell you how tall your text box is going to be so that you can set aside that much space in your image to draw it. This way you don't have to hard code the height of the text into the script.
iMagine Photo is also significantly faster at processing image files using applescript than GraphicConverter. Thanks to Jeff for the date part of the code.
Here is a link to download iMagine Photo. <http://www.yvs.eu.com/downloads/iMaginePhoto.dmg>
Documentation and info can be found on my website: http://www.yvs.eu.com
Kevin
on run
set cyear to year of (current date)
set cday to day of (current date)
set cmonth to month of (current date) as integer
set cDate to cyear & "." & cmonth & "." & cday
tell application "Finder"
set pathName to (choose folder with prompt "Choose Folder")
set fileList to every file of folder pathName whose name contains ".jpg"
set loopFinish to count of items of fileList
end tell
tell application "iMagine Photo"
repeat with i from 1 to loopFinish
set theFile to item i of fileList as alias
set thisImporter to import graphic theFile
set fName to file name of thisImporter
set nameDate to fName & " " & cDate as string
set textRecord to {standard text, font:"Arial", font size:18, drawing text:nameDate, start from:top left, start point:{0, 0}, color:{0, 0, 0}}
set {textWidth, textHeight} to get text dimensions with properties textRecord
set {x, y, xDim, yDim} to the natural bounds of thisImporter
set thisDocument to make new window document with properties {xDim, yDim + textHeight}}
-- set thisDocument to make new graphic document with properties {dimensions:{xDim, yDim + textHeight}} -- uncomment this line if you want to process offscreen. faster
set the drawing destination of thisImporter to thisDocument
set the top left point of thisImporter to {0, textHeight}
draw thisImporter
close thisImporter
set the export file location of thisDocument to theFile
set leftEdge to (xDim - textWidth) div 2
set the start point of textRecord to {leftEdge, 0}
tell thisDocument to create composition element with properties textRecord
-- set the export exif user data of thisDocument to theFile -- uncomment if you want keep the exif data.
export thisDocument
close thisDocument
end repeat
end tell
end run
On 10 Mar 2005, at 08:48, Jeff Shapiro wrote:
Robert Poland was seen on 3/9/05 6:14 PM talking about:
GraphicConverter 5.5.2, OS 10.3.8
With an Applescript I would like to be able to add the name and
current date (one line) to the margin of a picture.
You got me wondering so I tried quickly throw something together.
Here it is:
(Watch out for line wraps.)
This script prompts for a folder and adds a top margin then centers the
file name and current date in the new margin. There may be a bug in GC
because the "color" of draw textline doesn't seem to have any effect.
(It's always black.)
(I know this is probably a mess to the more experience scripters around
here; however, I'm new to AS and I really didn't want to spend a lot of
time on this :-)
-- Set up date variables
set cyear to year of (current date)
set cday to day of (current date)
set cmonth to month of (current date) as integer
set cDate to cyear & "." & cmonth & "." & cday
tell application "Finder"
--activate
set pathName to (choose folder with prompt "Choose Folder")
set fileList to every file of folder pathName whose name contains
".jpg"
set loopFinish to count of items of fileList
end tell
tell application "GraphicConverter"
repeat with i from 1 to loopFinish
set currentFile to item i of fileList
open currentFile as alias
set fname to name of window 1
set nameDate to fname & " " & cDate as string
tell window 1
set {picWidth, picHeight} to image dimension
set picCenter to picWidth / 2 as integer
change margins with {0, 28, 0, 0}
draw textline into text nameDate justification 2 color {0, 0, 0}
point {picCenter, 20} font "Arial" size 18 with antialias
end tell
save window 1 with wwwready
close window 1
end repeat
quit yes
end tell
----
--
Listserv only address.
Jeff Shapiro
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden