ndio/convert/png.py
def save_collection(png_filename_base, numpy_data, start_layers_at=1):
    """
    Export a numpy array to a set of png files, with each Z-index 2D
    array as its own 2D file.

    Arguments:
        png_filename_base:     A filename template, such as "my-image-*.png"
                                which will lead to a collection of files named
                                "my-image-0.png", "my-image-1.png", etc.
        numpy_data:             The numpy array data to save to png.

    Returns:
        Array. A list of expanded filenames that hold png data.
    """
    file_ext = png_filename_base.split('.')[-1]
    if file_ext in ['png']:
        # Filename is "name*.ext", set file_base to "name*".
        file_base = '.'.join(png_filename_base.split('.')[:-1])
    else:
        # Filename is "name*", set file_base to "name*".
        # That is, extension wasn't included.
        file_base = png_filename_base
        file_ext = ".png"

    file_base_array = file_base.split('*')

    # The array of filenames to return
    output_files = []

    # Filename 0-padding
    i = start_layers_at
    for layer in numpy_data:
        layer_filename = (str(i).zfill(6)).join(file_base_array) + file_ext
        output_files.append(save(layer_filename, layer))
        i += 1

    return output_files
def save_collection(png_filename_base, numpy_data, start_layers_at=1):
    file_ext = png_filename_base.split('.')[-1]
    if file_ext in ['png']:
        # Filename is "name*.ext", set file_base to "name*".
        file_base = '.'.join(png_filename_base.split('.')[:-1])
    else:
        # Filename is "name*", set file_base to "name*".
        # That is, extension wasn't included.
        file_base = png_filename_base
        file_ext = ".png"

    file_base_array = file_base.split('*')

    # The array of filenames to return
    output_files = []

    # Filename 0-padding
    i = start_layers_at
    for layer in numpy_data:
        layer_filename = (str(i).zfill(6)).join(file_base_array) + file_ext
        output_files.append(save(layer_filename, layer))
        i += 1

    return output_files
def save_collection ( png_filename_base , numpy_data , start_layers_at = 1 ) : file_ext = png_filename_base . split ( '.' ) [ - 1 ] if file_ext in [ 'png' ] : # Filename is "name*.ext", set file_base to "name*". file_base = '.' . join ( png_filename_base . split ( '.' ) [ : - 1 ] ) else : # Filename is "name*", set file_base to "name*". # That is, extension wasn't included. file_base = png_filename_base file_ext = ".png" file_base_array = file_base . split ( '*' ) # The array of filenames to return output_files = [ ] # Filename 0-padding i = start_layers_at for layer in numpy_data : layer_filename = ( str ( i ) . zfill ( 6 ) ) . join ( file_base_array ) + file_ext output_files . append ( save ( layer_filename , layer ) ) i += 1 return output_files
Export a numpy array to a set of png files, with each Z-index 2D
    array as its own 2D file.

    Arguments:
        png_filename_base:     A filename template, such as "my-image-*.png"
                                which will lead to a collection of files named
                                "my-image-0.png", "my-image-1.png", etc.
        numpy_data:             The numpy array data to save to png.

    Returns:
        Array. A list of expanded filenames that hold png data.
Export a numpy array to a set of png files with each Z - index 2D array as its own 2D file .