Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR ACTIONSCRIPT

how to resize a base64 image

function imageToDataUri(img, width, height) {

    // create an off-screen canvas
    var canvas = document.createElement('canvas'),
        ctx = canvas.getContext('2d');

    // set its dimension to target size
    canvas.width = width;
    canvas.height = height;

    // draw source image into the off-screen canvas:
    ctx.drawImage(img, 0, 0, width, height);

    // encode image to data-uri with base64 version of compressed image
    return canvas.toDataURL();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #resize #image
ADD COMMENT
Topic
Name
9+1 =