Re: Math-a-magic puzzle
Re: Math-a-magic puzzle
- Subject: Re: Math-a-magic puzzle
- From: Nathan Greenstein <email@hidden>
- Date: Sun, 1 Aug 2010 06:50:53 -0700
How about adding this:
set picWidth to picWidth/10
set picWidth to round picWidth
set picWidth to picWidth*10
This will temporarily change your variable to 49.9, round it to a whole number (50), and then multiply it by ten (500).
The same thing will work for any number that you want to round to a certain number of decimal places.
--
On Sat, Jul 31, 2010 at 21:15,
email@hidden <email@hidden> wrote:
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden