Best quality image Downscaling with Canvas
download from: JS Classes




Original image

Browser resized
original width: px
original height: px

Show original in full size

Resized canvas

Resizer resized
new width: px
new height: px

var args = {
    source: 'undefined',           // string (querySelector) or html img element
    keepRatio: true,               // boolean
    height: 450,                   // int
    width: 450,                    // int
    level: 0,                      // int 0-9
/*
       0: AUTO,
       1: SHARP_HIGH,
       2: SHARP_MEDIUM,
       3: SHARP_LOW,
       4: OPTIMAL_LOW,
       5: OPTIMAL_MEDIUM,
       6: OPTIMAL_HIGH,
       7: SMOOTH_LOW,
       8: SMOOTH_MEDIUM,
       9: SMOOTH_HIGH
*/
    smoothEnabled: true,           // boolean
};

function resultCallBack(res) {
    // res.source    - source img element
    // res.canvas    - resized canvas
    // res.dataURL   - image data
    // res.width     - resized width
    // res.height    - resized height
    // res.startTime
    // res.endTime 
};

new Resizer().Init(args, resultCallBack);