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 17:07:45 -0400
- Organization: [very little]
>
Date: Tue, 23 Oct 2001 09:13:13 -0700
>
To: email@hidden
>
From: Landis <email@hidden>
>
Subject: Re: Scaling large images w/ Akua Sweets
>
>
Thanks for the great and rapid responses. I appreciate the help.
>
I've gotten three replies so far, and have tried all three methods
>
without succes.
Here's a script I use all the time, employing Akua Sweets to reduce
images to a maximum dimension.
property maxDim : 640
on run
open ({choose folder})
end run
on open (theItems)
if (count of theItems) > 1 then
display dialog "This script is set up to process a single folder
of JPEG images" buttons {"OK"} default button 1 with icon stop
error number -128
end if
set theFldr to (contents of item 1 of theItems)
if character -1 of (theFldr as text) is not ":" then
display dialog "This script is set up to process a single folder
of JPEG images" buttons {"OK"} default button 1 with icon stop
error number -128
end if
tell application "Finder"
set fileCnt to count (files of theFldr whose file type is "JPEG")
if fileCnt < 1 then
display dialog "No JPEG files were found in the input"
buttons {"OK"} default button 1 with icon stop
error number -128
else if fileCnt > 1 then
set fileList to (files of theFldr whose file type is "JPEG")
as alias list
else
set fileList to (files of theFldr whose file type is "JPEG")
as alias as list
end if
set destFldr to (choose folder with prompt "Choose the
destination folder:")
open destFldr
set view of destFldr to 2
end tell
set convCnt to 0
repeat with aFile in fileList
set theFile to contents of aFile
set AppleScript's text item delimiters to {":"}
set fileName to text item -1 of (theFile as text)
set AppleScript's text item delimiters to {""}
set theImage to the image from theFile
set {a, b, x, y} to picture bounds of (the picture info for theImage)
if x > maxDim or y > maxDim then
if x > y then
set y to round (y * (maxDim / x))
set x to maxDim
else
set x to round (x * (maxDim / y))
set y to maxDim
end if
end if
set theImage to scale image theImage to {0, 0, x, y}
store image theImage in ((destFldr as text) & fileName) [optn-L]
as "JPEG" with percent quality 75
apply catalog info {file creator:"GKON"} to alias ((destFldr as
text) & fileName)
set convCnt to convCnt + 1
end repeat
if convCnt > 1 then
set theText to (convCnt as text) & " images were converted"
else
set theText to "One image was converted"
end if
say "Conversion completed" using "Fred"
say theText using "Fred"
activate
display dialog theText buttons {"OK"} default button 1 [optn-L]
with icon note giving up after 15
end open
Watch out for line wraps. "[optn-L]" stands in for the continuation character.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[10/23/01 5:05:58 PM]