how to resize a base64 image

import flash.display.Loader;
import flash.utils.ByteArray;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Matrix;

function resizeBase64Image(base64Image:String, newWidth:Number, newHeight:Number):Bitmap {
    var decodedBytes:ByteArray = Base64.decode(base64Image);

    var loader:Loader = new Loader();
    loader.loadBytes(decodedBytes);

    var bitmap:Bitmap = Bitmap(loader.content);
    var originalWidth:Number = bitmap.width;
    var originalHeight:Number = bitmap.height;

    var scaleWidth:Number = newWidth / originalWidth;
    var scaleHeight:Number = newHeight / originalHeight;

    var matrix:Matrix = new Matrix();
    matrix.scale(scaleWidth, scaleHeight);

    var resizedBitmapData:BitmapData = new BitmapData(newWidth, newHeight);
    resizedBitmapData.draw(bitmap, matrix, null, null, null, true);

    return new Bitmap(resizedBitmapData);
}