set theFile to choose file
tell application "GraphicConverter"
activate
open theFile
-- set image dimension of window 1 to {3264, 2448}
set {picWidth, picHeight} to image dimension of window 1
set scale500 to (500 / picWidth)
scale window 1 horizontal scale500 vertical scale500
repeat
set {picWidth, picHeight} to image dimension of window 1
if picWidth < 500 then
scale window 1 horizontal 1.0025 vertical 1.0025
beep
delay 0.5
else
exit repeat
end if
end repeat
tell application "System Events"
activate
display dialog "Width=" & picWidth
end tell
-- save window 1 in (destFldr & theName & "_500")
close window 1 saving no
end tell
On Jul 31, 2010, at 7:36pm, Robert Poland wrote:
Hi,
I've got a challenge for the math-a-magicians out there.
Using the script below on a picture 3264x2448 i get a result in the display Dialog for 499 pixels.
THE CHALLENGE:
Is there a simple fix to get a result of 500 pixels?
Well, this isn't a math-magical solution, but it seems to work.
What's happening is that GC is doing some internal rounding that you have no control over, but incrementally adjusting the scale can work.
Also, you're script included several calls to system events that weren't necessary and a few commands to activate system events that I don't think are needed.
HTH,
ES
set theFile to chooseFile
tell application "GraphicConverter"
activate
open theFile
--set image dimension of window 1 to {3264, 2448}
set {picWidth, picHeight} to image dimension of window 1
set scale500 to (500 / picWidth)
scale window 1 horizontal scale500 vertical scale500
repeat
set {picWidth, picHeight} to image dimension of window 1
if picWidth < 500 then
scale window 1 horizontal 1.0025 vertical 1.0025
else
exit repeat
end if
end repeat
display dialog "Width=" & picWidth
-- save window 1 in (destFldr & theName & "_500")
close window 1 saving no
end tell