Miscellaneous

Description

Unlike the composition module, this section focuses on managing images instead of editing them, no matter what the module is editing. Functions and classes in this module include image classes and image import functions.

Function List

class pyifx.misc.ImageVolume(input_path, output_path, prefix='_', level=1)

A class used to import images from a directory into Python, creating a list of PyifxImage instances.

Variables:
  • input_path (str) – The path to the directory where the images are located.
  • output_path (str) – The path where images in the volume should be saved.
  • prefix (str) – The prefix for edited image file names.
  • volume (list) – The list of images imported from the input path.
__init__(self, input_path, output_path, prefix="_", level=1)

The ImageVolume constructor method.

Parameters:
  • input_path (str) – The path to the directory where the images are located.
  • output_path (str) – The path where images in the volume should be saved.
  • prefix (str) – The prefix for edited image file names. If nothing is entered for this parameter, it will default to “_”.
  • level (int) – The depth to which images should be imported from subdirectories. For infinite depth, set this value to 0. If nothing is entered, this value will default to 1, importing from the root directory exclusively.
Returns:

ImageVolume instance

Return type:

pyifx.misc.ImageVolume

__weakref__

list of weak references to the object (if defined)

convert_dir_to_images(input_dir, level=1)

convert_dir_to_images(input_dir, level=1): Converts files from a given directory into PyifxImage instances.

Parameters:
  • input_dir (str) – The directory to read files from.
  • level (int) – The depth to which images should be imported from subdirectories. For infinite depth, set this value to 0. If nothing is entered, this value will default to 1, importing from the root directory exclusively.
Returns:

List with elements of type PyifxImage

Return type:

list

get_input_path()

get_input_path(self): Gets the instances input path and returns it.

Returns:Input path
Return type:str
get_output_path()

get_output_path(self): Gets the instances output path and returns it.

Returns:Output path
Return type:str
get_prefix()

get_prefix(self): Gets the instances prefix property and returns it.

Returns:Prefix
Return type:str
get_volume()

get_volume(self): Gets the instances volume and returns it.

Returns:List of images of type PyifxImage OR An empty array
Return type:list
set_input_path(new_input_path, level=1)

set_input_path(self, new_input_path, level=1): Sets the instances input path and returns it.

Parameters:
  • new_input_path (str) – What the input path will be set to.
  • level (int) – The depth to which images should be imported from subdirectories. For infinite depth, set this value to 0. If nothing is entered, this value will default to the previously set level of the class.
Returns:

ImageVolume instance

Return type:

pyifx.misc.ImageVolume

set_output_path(new_output_path)

set_output_path(self, new_output_path): Sets the instances output path and returns the instance.

Parameters:new_output_path (str) – What the output path will be set to.
Returns:ImageVolume instance
Return type:pyifx.misc.ImageVolume
set_prefix(new_prefix)

set_prefix(self, new_prefix): Sets the instances prefix property and returns the instance.

Parameters:new_prefix (str) – What the instances prefix property will be set to.
Returns:ImageVolume instance
Return type:pyifx.misc.ImageVolume
set_volume(new_volume)

set_volume(self, new_volume): Sets the instances volume property and returns the volume.

Parameters:new_volume (list) – What the instances volume will be set to.
Returns:ImageVolume instance
Return type:pyifx.misc.ImageVolume
volume_to_list(self, level=1)

The method used to create a list of PyifxImage instances based on the arguments entered in the constructor method. The volume property will be set based on the return value of this function.

Parameters:level (int) – The depth to which images should be imported from subdirectories. For infinite depth, set this value to 0. If nothing is entered, this value will default to 1, importing from the root directory exclusively.
Returns:PyifxImage list
Return type:list
class pyifx.misc.PyifxImage(input_path, output_path=None, img=None, create_image=True)

A class used to create packages of images & their properties created for use with the Pyifx library.

Variables:
  • input_path (str, NoneType) – The path to where the image is located. If the image does not have an input path, it means that the instance is a result of combining two or more images.
  • output_path (str, NoneType) – The path to where edited images should be created. If the image does not have an output path, it means the instance is used for read-only purposes.
  • image (numpy.ndarray, NoneType) – The image located at the input path in the form of a numpy n-dimensional array. If the instance does not have an image property, it means that the image had not been read.
__init__(self, path, output_path=None, img=None, create_image=True)

The PyifxImage constructor method.

Parameters:
  • path (str, NoneType) – The path to where the image is located. Only use None as a value if the image property of the instace is being specified.
  • output_path (str, NoneType) – The path to where the edited image should be saved. Only use None as a value if the instance is not going to be saved to a file.
  • img (numpy.ndarray, NoneType) – The data used for image editing & processing. The image property of the class will be set based on the input path unless this parameter is set to a value other than None.
  • create_image (bool) – Specify whether the image property should be read from the input path. If this is set to true, the image at the input path will override the specified image parameter.
Returns:

PyifxImage instance

Return type:

pyifx.misc.PyifxImage

__weakref__

list of weak references to the object (if defined)

get_image()

get_image(self): Gets the instances image data and returns it.

Returns:Image data
Return type:numpy.ndarray
get_input_path()

get_input_path(self): Gets the instances input path and returns it.

Returns:Input path
Return type:str
get_output_path()

get_output_path(self): Gets the instances output path and returns it.

Returns:Output path
Return type:str
refresh_image()

refresh_image(self): Re-reads image based on input path & overrides the current image property, then returns the instance.

Returns:PyifxImage instance
Return type:pyifx.misc.PyifxImage
set_image(new_image)

set_image(self, new_image): Sets the instances image data and returns it.

Parameters:new_image (numpy.ndarray) – What the image property will be set to.
Returns:PyifxImage instance
Return type:pyifx.misc.PyifxImage
set_input_path(new_input_path)

set_input_path(self, new_input_path): Sets the instances input path and returns the instance.

Parameters:new_input_path (str) – What the input path will be set to.
Returns:PyifxImage instance
Return type:pyifx.misc.PyifxImage
set_output_path(new_output_path)

set_output_path(self, new_output_path): Sets the instances output path and returns the instance.

Parameters:new_output_path (str) – What the output path will be set to.
Returns:PyifxImage instance
Return type:pyifx.misc.PyifxImage
pyifx.misc.combine(img1, img2, out_path, write=True)

Combines the data of two PyifxImages, ImageVolumes, or ImageLists to form new PyifxImages.

Parameters:
  • img1 (pyifx.misc.PyifxImage, pyifx.misc.ImageVolume, list) – The first image to be added to the combination.
  • img2 (pyifx.misc.PyifxImage, pyifx.misc.ImageVolume, list) – The second image to be added to the combination. Arguments of type ImageVolume and list can be used in conjunction, but images of type PyifxImage must be used together.
  • out_path (str) – The path that the combine image(s) will be written to.
  • write (bool) – Whether to write the image or not.
Returns:

PyifxImage instance, ImageVolume instance, or list with elements of type PyifxImage

Return type:

pyifx.misc.PyifxImage, pyifx.misc.ImageVolume, list