If image width bigger than height [duplicate]

Use wp_get_attachment_metadata().

Using your example:

$img_data = wp_get_attachment_metadata( $attachment_id );
$w = $img_data['width'];
$h = $img_data['height'];

if ($w > $h) {
    $class = "col-sm-12";
} else {
    $class = "col-sm-6";
}

Though, to get the attachment ID, you’ll either have to put a filter that acts on every image or create a loop that uses featured images.