• 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: "email@hidden" <email@hidden>
  • Date: Sun, 1 Aug 2010 08:59:53 -0700



The example sent by email@hidden does scale a 2749 x 5399 picture to 500 x 981.



After giving this some more thought, this is, I think, a better solution.

When working with graphics it's always better to scale down. If you scale up, you're adding information, and the first solution I posted was scaling up on images that didn't round to a width of 500 pixels.

The challenge, of course, is to make sure the height is multiplied (or divided) by the same amount as the width in scaling the image.  Since we know what the new width dimension will be, we can get the aspect ratio (w/h) of the image, and use that to determine the new height.  

I also broke the scaling commands into a handler, which is how I'd implement this. You may notice a difference of one pixel from the scaling GC does.  That's because the GC rounding method is different from AppleScript's. 

HTH,

ES



tell application "GraphicConverter"
activate
open theFile
set image dimension of window 1 to {3264, 2448}
set {picWidth, picHeight} to my ScaleImage()
display dialog "Width= " & picWidth & " Height= " & picHeight 
-- save window 1 in (destFldr & theName & "_500")
--close window 1 saving no
end tell

 

 on ScaleImage()
tell application "GraphicConverter"
set {picWidth, picHeight} to image dimension of window 1
set image dimension of window 1 to {500, round (500 / (picWidth / picHeight))}
return image dimension of window 1
end tell
end ScaleImage


 _______________________________________________
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: "Mark J. Reed" <email@hidden>
    • Re: Math-a-magic puzzle
      • From: Robert Poland <email@hidden>
References: 
 >Re: Math-a-magic puzzle (From: Luther Fuller <email@hidden>)
 >Re: Math-a-magic puzzle (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Math-a-magic puzzle
  • Next by Date: Re: Math-a-magic puzzle
  • Previous by thread: Re: Math-a-magic puzzle
  • Next by thread: Re: Math-a-magic puzzle
  • Index(es):
    • Date
    • Thread