def save(self, filename, flipped=False):
        '''Save image texture to file.

        The filename should have the '.png' extension because the texture data
        read from the GPU is in the RGBA format. '.jpg' might work but has not
        been heavilly tested so some providers might break when using it.
        Any other extensions are not officially supported.

        The flipped parameter flips the saved image vertically, and
        defaults to True.

        Example::

            # Save an core image object
            from kivy.core.image import Image
            img = Image('hello.png')
            img.save('hello2.png')

            # Save a texture
            texture = Texture.create(...)
            img = Image(texture)
            img.save('hello3.png')

        .. versionadded:: 1.7.0

        .. versionchanged:: 1.8.0
            Parameter `flipped` added to flip the image before saving, default
            to False.

        '''
        pixels = None
        size = None
        loaders = [x for x in ImageLoader.loaders if x.can_save()]
        if not loaders:
            return False
        loader = loaders[0]

        if self.image:
            # we might have a ImageData object to use
            data = self.image._data[0]
            if data.data is not None:
                if ('rgba', 'rgb') not in data.fmt:
                    # fast path, use the "raw" data when keep_data is used
                    size = data.width, data.height
                    pixels = data.data

                else:
                    # the format is not rgba, we need to convert it.
                    # use texture for that.
                    self.populate()

        if pixels is None and self._texture:
            # use the texture pixels
            size = self._texture.size
            pixels = self._texture.pixels

        if pixels is None:
            return False

        l_pixels = len(pixels)
        if l_pixels == size[0] * size[1] * 3:
            fmt = 'rgb'
        elif l_pixels == size[0] * size[1] * 4:
            fmt = 'rgba'
        else:
            raise Exception('Unable to determine the format of the pixels')
        return loader.save(filename, size[0], size[1], fmt, pixels, flipped)
dataset/ETHPy150Open kivy/kivy/kivy/core/image/__init__.py/Image.save/swapped operands of `not in`