• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Math-a-magic puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Math-a-magic puzzle


  • Subject: Re: Math-a-magic puzzle
  • From: Robert Poland <email@hidden>
  • Date: Sun, 1 Aug 2010 06:55:44 -0600

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 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 10:15 PM, 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


Robert Poland - Fort Collins, CO



 _______________________________________________
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

  • Follow-Ups:
    • Re: Math-a-magic puzzle
      • From: Brian Christmas <email@hidden>
  • Next by Date: Re: Math-a-magic puzzle
  • Next by thread: Re: Math-a-magic puzzle
  • Index(es):
    • Date
    • Thread