Re: Scaling large images w/ Akua Sweets
Re: Scaling large images w/ Akua Sweets
- Subject: Re: Scaling large images w/ Akua Sweets
- From: "Marc K. Myers" <email@hidden>
- Date: Tue, 23 Oct 2001 10:50:03 -0400
- Organization: [very little]
>
Date: Mon, 22 Oct 2001 17:11:41 -0700
>
To: email@hidden
>
From: Landis <email@hidden>
>
Subject: Scaling large images w/ Akua Sweets
>
>
I'm brand new to the list, and pretty new to scripting. Having
>
searched the archives of the list, I've gotten a lot of good examples
>
but I'm hoping that someone out there might be able to help me with
>
some specifics.
>
>
I've got lots of PICTs that are fairly large (40+ MB) that I need to
>
scale depending on their pixel dimensions. I normally use PhotoShop,
>
but without shelling out another $300 for a 3rd party scripting
>
extension, it's plain useless with AppleScript. Going thorough the
>
archives, I've found several mentions of Akua Sweets w/ examples
>
(pretty awesome stuff). I've gotten a lot of what I want done, but I
>
can't quite get the syntax for scaling and saving the new image.
>
>
Here's what I've got:
>
>
--BEGIN SCRIPT
>
set imgFile to (choose file with prompt "Choose any PICT file")
>
>
-- use "Akua Sweets"
>
-- check that Quicktime's image importer can read it
>
if (the image type in imgFile) is "PICT" then
>
>
-- get Mac 'pict' object from image file
>
set thePict to the image from imgFile with proxy return
>
>
-- get picture information
>
set picInfo to the picture info for thePict
>
>
-- get picture
>
set picBounds to picture bounds of picInfo -- {left, top,
>
right, bottom}
>
>
-- get width and height...
>
set WidthO to (item 3 of picBounds as string)
>
set HeightO to (item 4 of picBounds as string)
>
>
--calculate L, M, & S series sizes that will work
>
set HeightL to ((round (HeightO / 196)) * 196)
>
set WidthL to ((round (WidthO / 4)) * 4)
>
>
--scale image and save
>
set ImageL to (scale image thePict to {WidthL, HeightL})
>
set FileL to (choose file name with prompt "Save resized PICT as")
>
store image (scale image thePict to {WidthL, HeightL}) in
>
FileL as "PICT"
>
>
--Free the RAM
>
dispose proxy data thePict
>
>
end if
>
--END SCRIPT
>
>
The script seems to run just fine, but it doesn't actually save
>
anything. It asks me where I want the file, and what to call it,
>
then finishes up, but the new file never materializes. Also my RAM
>
seems to be getting used up (the partition for the Finder gets bigger
>
and bigger, but doesn't actually get used (or returned)). Any
>
suggestions or help that any one could bestow on a new scripter? If
>
anyone needs a 40MB PICT to try this out, let me know :)
>
(they're about 1500 pixels wide by 9500 tall).
I think your problem is that you've got the wrong kind of file reference
in your "store image" statement. Try changing
set FileL to (choose file name with prompt "Save resized PICT as")
to
set FileL to (choose file name with prompt "Save resized PICT as")
as text
and you should change
store image (scale image thePict to {WidthL, HeightL}) in FileL as "PICT"
to
store image ImageL in FileL as "PICT"
since you already scaled it two statements back and stored the result in "ImageL"
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[10/23/01 10:49:13 AM]