Page 1 of 1

revImageScale

Posted: Thu Oct 14, 2010 9:53 pm
by MikeinHawaii
During the 09 Developers Conference, Ben Beaumont mentioned a new function that would be available in *the next release* that would be called revImageScale that will automatically scale image files to the selected container size for you. (disk 5/12 Intoduction to revWeb Plugin & revlets. I have had no luck with locating it in the Live Code release. Perhaps under a different name. Anybody know??

Re: revImageScale

Posted: Wed Jan 19, 2011 10:57 pm
by Mark
Hi MikeinHawaii,

Maybe Ben was making a joke?

Here's a function that takes the dimensions of an image object and returns a new width and height of the object that will make it fit inside a second object.

Code: Select all

function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
  if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
    put theCdWidth / theImgWidth into myRatio
  else
    put theCdHeight / theImgHeight into myRatio
  end if
  put theImgWidth * myRatio into myNewWidth
  put theImgHeight * myRatio into myNewHeight
  return myNewWidth,myNewHeight
end rescale
theImgWidth and theImgHeight are the width and height of the image object. TheCdWidth and theCdHeight are the width and height of the destination object (or card or stack).

Best regards,

Mark