'Updates the width and height fields of the bmp image.
Raises:
BadImageError if the image string is not a valid bmp image.'

def _update_bmp_dimensions(self):

    size = len(self._image_data)
    if (size >= 18):
        header_length = struct.unpack('<I', self._image_data[14:18])[0]
        if (((header_length == 40) or (header_length == 108) or (header_length == 124) or (header_length == 64)) and (size >= 26)):
            (self._width, self._height) = struct.unpack('<II', self._image_data[18:26])
        elif ((header_length == 12) and (size >= 22)):
            (self._width, self._height) = struct.unpack('<HH', self._image_data[18:22])
        else:
            raise BadImageError('Corrupt    BMP    format')
    else:
        raise BadImageError('Corrupt    BMP    format')
