def from_array(cls, array, filename=None, channels=3, scale_to_range=False,
                   grayscale=False, channel_bitdepth=8,
                   has_alpha=False, palette=None):
        """
        Creates an image by using a provided array. The array may be ready to
        be written or still need fine-tuning via set_pixel().
        The array should not have more than 3 dimensions or the output might be
        unexpected.
        """
        if scale_to_range:
            amax = array.max()
            amin = array.min()
            _array = (2**channel_bitdepth - 1) * (array - amin) / (amax - amin)
        else:
            _array = array
        _array = numpy.rint(_array).astype(dtype=PNGWriter.get_dtype(channel_bitdepth))  # proper rounding
        return cls(_array, filename, channels=channels,
                   grayscale=grayscale, channel_bitdepth=channel_bitdepth,
                   has_alpha=has_alpha, palette=palette)
Creates an image by using a provided array. The array may be ready to
        be written or still need fine-tuning via set_pixel().
        The array should not have more than 3 dimensions or the output might be
        unexpected.