You need to get the bounding info and calculate the width and height values from the bounds.
// Bounds:
// + - - - - - - - [1] - - - - - - - +
// | |
// | |
// [0] [2]
// | |
// | |
// + - - - - - - - [3] - - - - - - - +
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
alert(
'Layer Bounds -' + '\r' +
'X1 - [0]: ' + app.activeDocument.activeLayer.bounds[0] + '\r' +
'Y1 - [1]: ' + app.activeDocument.activeLayer.bounds[1] + '\r' +
'X2 - [2]: ' + app.activeDocument.activeLayer.bounds[2] + '\r' +
'Y2 - [3]: ' + app.activeDocument.activeLayer.bounds[3] + '\r' +
'Width: ' + (app.activeDocument.activeLayer.bounds[2].value - app.activeDocument.activeLayer.bounds[0].value) + ' px\r' +
'Height: ' + (app.activeDocument.activeLayer.bounds[3].value - app.activeDocument.activeLayer.bounds[1].value) + ' px'
);
app.preferences.rulerUnits = savedRuler;