Re: Scaling large images w/ Akua Sweets
Re: Scaling large images w/ Akua Sweets
- Subject: Re: Scaling large images w/ Akua Sweets
- From: Chris Adams <email@hidden>
- Date: Tue, 23 Oct 2001 05:55:06 +0000
On 10/23/01 12:11 AM Landis wrote:
>
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.
Here is a technique that uses Quicktime and applescript to scale (in pixels)
and save images. The trick is to save a "dummy" file name using the finder
that the image can then be "saved as." This script is part of a larger
script that can be run in a loop over a folder of images. This larger
script also compresses the images using media cleaner.
Larger script is here:
http://www.cypresslakestudios.com/applescript/index.html#photo_albummer
-- cut and paste this script into the script editor
-- **************************************************************
--Process one picture
-- **************************************************************
-- you need to establish mediumTargetHeight and mediumTargetWidth
-- and also smallTargetHeight and smallTargetWidth for thumbnails
-- the script will then scale the picture to these target sizes
-- keeping the aspect ratio the same.
on processPicture(currentFileAlias)
-- open in QT & get height and width
tell application "QuickTime Player"
activate
open currentFileAlias
set mydimensions to dimensions of movie 1 as list
set width to item 1 of mydimensions
set height to item 2 of mydimensions
-- save in largeFolder
-- this command establishes a copy of the image file called tempFile
-- saves the image at its original size
tell application "Finder"
set tempFile to (duplicate currentFileAlias to largeFolder) as alias
end tell
-- ************************************
-- export medium and small versions of the picture
-- ************************************
-- this takes the large size and performs a fomula based on the
-- mediumTargetWidth
if height < mediumTargetHeight and width < mediumTargetWidth then
set mediumWidth to width
set mediumHeight to height
else
if width > height then -- use target width
set aspect to height / width
-- checks aspect ratio of picture: if tall then use target height, if wide
than width
set mediumWidth to mediumTargetWidth
set mediumHeight to mediumTargetWidth * aspect div 1
set dimensions of movie 1 to {mediumWidth, mediumHeight}
else
if width < height then -- use target height
set aspect to height / width
-- checks aspect ratio of picture: if tall then use target height, if wide
than width
set mediumHeight to mediumTargetHeight
set mediumWidth to mediumTargetHeight div aspect
set dimensions of movie 1 to {mediumWidth, mediumHeight}
end if
end if
end if
end tell
-- save in mediumFolder
tell application "Finder"
set tempFile to (duplicate currentFileAlias to mediumFolder) as alias
end tell
tell application "QuickTime Player"
export movie 1 to tempFile as picture using default settings
end tell
-- small picture
tell application "QuickTime Player"
if width > height then -- use target width
set aspect to height / width
-- checks aspect ratio of picture: if tall then use target height, if wide
then width
set smallWidth to smallTargetWidth
set smallHeight to smallTargetWidth * aspect div 1
set dimensions of movie 1 to {smallWidth, smallHeight}
else
if width < height then -- use target height
set aspect to height / width
-- checks aspect ratio of picture: if tall then use target height, if wide
than width
set smallHeight to smallTargetHeight
set smallWidth to smallTargetHeight div aspect
set dimensions of movie 1 to {smallWidth, smallHeight}
end if
end if
-- save in smallFolder
tell application "Finder"
set tempFile to (duplicate currentFileAlias to smallFolder) as alias
end tell
tell application "QuickTime Player"
export movie 1 to tempFile as picture using default settings
-- finish
close movie 1 saving no
end tell
end tell
end processPicture
-- end script
--
Chris Adams
Cypress Lake Studios
Hypermedia, Quicktime, and Internet Design
http://www.cypresslakestudios.com
email@hidden