def to_image(self, filename='palette.png', band_width=1, length=60,
                 max_width=0, vertical=True, alpha_channel=False):
        """
        Creates an image from the palette.

        Args:
            filename(Optional[string]): filename of saved file. Defaults to
                ``palette.png`` in the current working directory.
            band_width(optional[int]): how wide each colour band should be.
                Defaults to 1 pixel.
            length(Optional[int]): the length of the overall image in pixels.
                This is the dimension orthogonal to ``band_width``. Defaults
                to 60 pixels.
            max_width(Optional[int]): if ``band_width`` is not set and this is,
                this determines how wide the whole image should be.
            vertical(Optional[bool]): if the image runs vertical (``True``,
                default) or horizontal (``False``).
            alpha_channel(Optional[bool]): if ``True``, the created image will
                have an Alpha channel. Defaults to ``False``.
        """
        # max_width is approximate
        # generate output pictures for documentation automatically

        if max_width < 1:
            pass
        else:
            band_width = int(max_width/len(self._colours))

        image_width = band_width * len(self._colours)

        if alpha_channel:
            my_image = Image.new('RGBA', (image_width, length))
        else:
            my_image = Image.new('RGB', (image_width, length))
        image_loaded = my_image.load()

        x = 0
        for my_colour in self._colours:
            for x1 in range(band_width):
                for y in range(length):
                    image_loaded[x, y] = my_colour.rgb()
                x = x + 1

        if vertical:
            my_image = my_image.rotate(270)

        my_image.save(filename)
def to_image ( self , filename = 'palette.png' , band_width = 1 , length = 60 , max_width = 0 , vertical = True , alpha_channel = False ) : if max_width < 1 : pass else : band_width = int ( max_width / len ( self . _colours ) ) image_width = band_width * len ( self . _colours ) if alpha_channel : my_image = Image . new ( 'RGBA' , ( image_width , length ) ) else : my_image = Image . new ( 'RGB' , ( image_width , length ) ) image_loaded = my_image . load ( ) x = 0 for my_colour in self . _colours : for x1 in range ( band_width ) : for y in range ( length ) : image_loaded [ x , y ] = my_colour . rgb ( ) x = x + 1 if vertical : my_image = my_image . rotate ( 270 ) my_image . save ( filename )
Creates an image from the palette.

        Args:
            filename(Optional[string]): filename of saved file. Defaults to
                ``palette.png`` in the current working directory.
            band_width(optional[int]): how wide each colour band should be.
                Defaults to 1 pixel.
            length(Optional[int]): the length of the overall image in pixels.
                This is the dimension orthogonal to ``band_width``. Defaults
                to 60 pixels.
            max_width(Optional[int]): if ``band_width`` is not set and this is,
                this determines how wide the whole image should be.
            vertical(Optional[bool]): if the image runs vertical (``True``,
                default) or horizontal (``False``).
            alpha_channel(Optional[bool]): if ``True``, the created image will
                have an Alpha channel. Defaults to ``False``.