class SAPO.Utility.Image
Useful methods for image manipulation and layout
 
Authors:
jose.p.dias AT co.sapo.pt requires SAPO.Dom.Event
Version:
0.1
Since:
June 2011
Defined in Utility/Image/0.1/lib.js

Function Summary
loadImageOffline (String url, Function(url, dims, params) cb, [Object params])
- loads an image offline and returns its dimensions to the given callback
Number[] maximizeBox (Number[] maxSz, Number[] imageSz, [Boolean forceMaximize])
- returns the maximum box inside maxSz keeping imageSz aspect ratio

Function Details

function loadImageOffline

loadImageOffline(String url, Function(url, dims, params) cb, [Object params])
- loads an image offline and returns its dimensions to the given callback
Parameters:
url - image url
cb - callback to call once dimensions are known
[params] - optional params to pass as callback's 3rd argument
  • [ Boolean trackLoad ] - if trueish, loading time is returned as loadDuration (in milisseconds)
  • [ Number timeout ] - if passed, an image taking more that timeout milisseconds is returned via the cb. Pay attention that in this case dims is returned undefined!

function maximizeBox

Number[] maximizeBox(Number[] maxSz, Number[] imageSz, [Boolean forceMaximize])
- returns the maximum box inside maxSz keeping imageSz aspect ratio
Parameters:
maxSz - the maximum resolution we're willing to accept
imageSz - the original image size
[forceMaximize] - if true, images smaller than maxSz will be scaled up