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

def _update_ico_dimensions(self):

    size = len(self._image_data)
    if (size >= 8):
        (self._width, self._height) = struct.unpack('<BB', self._image_data[6:8])
        if (not self._width):
            self._width = 256
        if (not self._height):
            self._height = 256
    else:
        raise BadImageError('Corrupt    ICO    format')
