REBOL [ title: "Calculate Image Aspect Ratio" date: 13-Mar-2008 author: ["James Irwin" "The Untitled One"] email: rebolyte--gmail--com license: ['MIT http://www.opensource.org/licenses/mit-license.php] ] calc-ratio: calculate-image-aspect-ratio: func [ "Calculate a new aspect ratio from given dimensions." image-size [pair!] "Size of original image." desired [integer!] "New desired width." /height "Instead of width, specify new desired height." ][ orig-width: first image-size orig-height: second image-size either height [ ; Use height variable x: orig-width * desired desired-opposite: round/half-ceiling x / orig-height res: to pair! rejoin [desired-opposite "x" desired] ][ ; Use width variable x: orig-height * desired desired-opposite: round/half-ceiling x / orig-width res: to pair! rejoin [desired "x" desired-opposite] ] ] print {Enter something like "calc-ratio 1024x786 800".} print {Enter "help calc-ratio" to see more on how to use this function.} halt