Re: Math-a-magic puzzle
Re: Math-a-magic puzzle
- Subject: Re: Math-a-magic puzzle
- From: Brian Christmas <email@hidden>
- Date: Sun, 1 Aug 2010 23:56:05 +1000
G'day
Methinks you've forgotten that the dimensions start with zero, so you'll always round down
Try the following
Regards
Santa
On 01/08/2010, at 10:55 PM, Robert Poland wrote: Thanks Ed,
I modified your script to see just how many loop happened. See below. Also added a space in chooseFile.
The extra calls to system events were left over from the removed Display dialog.
I like to do that so the dialog box is in front.
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 picWidth to picWidth +1 set picHeight to picHeight +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
Robert Poland - Fort Collins, CO
And what, you ask, was the beginning of it all? And it is this...... Existence that multiplied itself For sheer delight of being And plunged with numberless trillions of forms So that it might find itself innumerably
Sri Aurobindo
|
_______________________________________________
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