def vips_image_new_from_array(cls, array, scale = 1, offset = 0):
    """Create a new image from an array.

    The array argument can be a 1D array to create a height == 1 image, or a 2D
    array to make a 2D image. Use scale and offset to set the scale factor,
    handy for integer convolutions. 
    """
    # we accept a 1D array and assume height == 1, or a 2D array and check all
    # lines are the same length
    if not isinstance(array, list):
        raise TypeError('new_from_array() takes a list argument')
    if not isinstance(array[0], list):
        height = 1
        width = len(array)
    else:
        # must copy the first row, we don't want to modify the passed-in array
        flat_array = list(array[0])
        height = len(array)
        width = len(array[0])
        for i in range(1, height):
            if len(array[i]) != width:
                raise TypeError('new_from_array() array not rectangular')
            flat_array += array[i]
        array = flat_array

    image = cls.new_matrix_from_array(width, height, array)

    # be careful to set them as double
    image.set('scale', float(scale))
    image.set('offset', float(offset))

    return image