Re: filename to bitmap
Re: filename to bitmap
- Subject: Re: filename to bitmap
- From: Brennan <email@hidden>
- Date: Tue, 16 Oct 2001 01:23:55 +0200
On 15/10/01 at 1:37 pm, email@hidden wrote:
>
> matthew blair <email@hidden> wrote
>
>
>
> Im trying to put a fllename slug into a Jpeg image for marking filenames on
>
> digital photographs is it posible to clipboard text as pict file as in turn
>
> the filename text into a pict (bitmapped) slug
>
>
>
> I use photoshop for most of my image processing but the batching environment
>
> prohibits me from annotating my prints with filenames and I need to track
>
> prints by name , photoshops contact sheet manages to retrive file names but
>
> the command is not available in the actions
>
Irwin Poche <email@hidden> wrote
>
>
AppleWorks can probably do this. It has Applescript support.
Yes, but that's probably a bit heavy for so simple a task.
>
Adobe Photoshop has it's own scripting language which can be invoked with an
>
Applescript "do script" command.
I find Photoshop's 'scripting language' (ha ha) wholly inadequate for anything but the most linear tasks.
Intelligent file naming for example based on the original file name, is particularly lacking. I'm hoping the GIMP (already running on OSX!) will kick Adobe a bit into improving this feature.
>
It might be possible with QuickTime's movie player. I've had times when I
>
opened a text file and was presented a rendering of the text. I don't
>
remember the conditions under which it will work or if it still does.
Again, doable, but a little heavy. You have to create a text file with the right draw settings, and then import it, then add it to your image using the clipboard, then export it again as a still. Fiddly, and not particularly fast.
My preference is Akua sweets, which exposes most of Quickdraw to applescript. You create a draw window, in this case offscreen, and use Quickdraw to draw a string into it, then capture the image back and store it in the file the original came from. This script works both as a droplet and as a double clickable app - even in script editor. As a droplet (of course) you can process multiple files at once, which might be useful.
The output file gets the system default creator for JPEGs, which may not be the one you like, or the one you started with. You can change this by adding some more code, such as going through the Finder, but that's the easy part.
It's white text in monaco 14 point. You can change this to whatever you like (see 'text settings' below) as well as the position of the text.
Here goes:
on open (dropped) -- for droplet
repeat with f in dropped
textLabel(f)
end repeat
end open
on run -- for applet, or running from script editor
set f to (choose file)
textLabel(f)
end run
on textLabel(f)
set fname to (name of (info for f)) -- the string we will draw into the file
set iType to (the image type in f)
if iType is "" then
set msg to "Can't read \"" & fname & "\" as an image."
set b to {"Rats"}
display dialog msg buttons b default button 1
return
end if
set p to ((the image from f) as picture)
set pInfo to (the picture info for p)
set pQuality to (picture compressed quality of pInfo)
-- text settings (change this to whatever you want)...
set textPos to {10, 14}
set dState to {text font:"Monaco"}
set dState to dState & {text size:14}
set dState to dState & {justification:left}
set dState to dState & {pen color:"ffffff"} -- i.e. white
set dState to dState & {transfer mode:1} -- i.e. background transparent
try
set drawWindow to (display drawing "offscreen" located at {-2, -2} starting with p)
quickdraw a string into drawWindow at textPos using data fname using state dState
set modifiedPicture to ((capture picture from drawWindow) as picture)
display drawing drawWindow with disposal
on error msg number n -- make sure we close the window if something went wrong...
display dialog msg & (n as string)
display drawing drawWindow with disposal
end try
store image modifiedPicture in f as "JPEG" with percent quality pQuality with overwriting
end textLabel
-Brennan