'Updates the width and height fields of the image.
Raises:
NotImageError if the image data is not an image.
BadImageError if the image data is corrupt.'

def _update_dimensions(self):

    if (not self._image_data):
        raise NotImageError('Dimensions    unavailable    for    blob    key    input')
    size = len(self._image_data)
    if ((size >= 6) and self._image_data.startswith('GIF')):
        self._update_gif_dimensions()
        self._format = GIF
    elif ((size >= 8) and self._image_data.startswith('\x89PNG\r\n\x1a\n')):
        self._update_png_dimensions()
        self._format = PNG
    elif ((size >= 2) and self._image_data.startswith('\xff\xd8')):
        self._update_jpeg_dimensions()
        self._format = JPEG
    elif ((size >= 8) and (self._image_data.startswith('II*\x00') or self._image_data.startswith('MM\x00*'))):
        self._update_tiff_dimensions()
        self._format = TIFF
    elif ((size >= 2) and self._image_data.startswith('BM')):
        self._update_bmp_dimensions()
        self._format = BMP
    elif ((size >= 4) and self._image_data.startswith('\x00\x00\x01\x00')):
        self._update_ico_dimensions()
        self._format = ICO
    elif ((size >= 16) and (self._image_data.startswith('RIFF', 0, 4) and self._image_data.startswith('WEBP', 8, 12) and self._image_data.startswith('VP8    ', 12, 16))):
        self._update_webp_dimensions()
        self._format = WEBP
    elif ((size >= 16) and (self._image_data.startswith('RIFF', 0, 4) and self._image_data.startswith('WEBP', 8, 12) and self._image_data.startswith('VP8X', 12, 16))):
        self._update_webp_vp8x_dimensions()
        self._format = WEBP
    else:
        raise NotImageError('Unrecognized    image    format')
