demos/Collage/fabric.js
function getSizeInPixels(el, value) {
    if (/px$/i.test(value)) return parseFloat(value);
    var style = el.style.left, runtimeStyle = el.runtimeStyle.left;
    el.runtimeStyle.left = el.currentStyle.left;
    el.style.left = value;
    var result = el.style.pixelLeft;
    el.style.left = style;
    el.runtimeStyle.left = runtimeStyle;
    return result;
  }
function getSizeInPixels(el, value) {
    if (/px$/i.test(value)) return parseFloat(value);
    var style = el.style.left, runtimeStyle = el.runtimeStyle.left;
    el.runtimeStyle.left = el.currentStyle.left;
    el.style.left = value;
    var result = el.style.pixelLeft;
    el.style.left = style;
    el.runtimeStyle.left = runtimeStyle;
    return result;
  }
function getSizeInPixels ( el , value ) { if ( / px$ / i . test ( value ) ) return parseFloat ( value ) ; var style = el . style . left , runtimeStyle = el . runtimeStyle . left ; el . runtimeStyle . left = el . currentStyle . left ; el . style . left = value ; var result = el . style . pixelLeft ; el . style . left = style ; el . runtimeStyle . left = runtimeStyle ; return result ; }
Original by Dead Edwards. Combined with getFontSizeInPixels it also works with relative units.
Original by Dead Edwards . Combined with getFontSizeInPixels it also works with relative units .