def convertion(): # first initializes the Imagetools class test_image = ImageTools(TEST_IMAGE_DIR) # Then calls the file extension converter test_image.convertFile( ".png", '..\\result_images', True ) # in this test, we're converting a .jfif image file into a .png image file
def test_graph(): DEST_PATH = os.path.abspath('./docs/test_utils/result_images') SRC_PATH = os.path.join(os.path.abspath('.'), "Graph#1.jpeg") TEST_PATH = os.path.join(DEST_PATH, "Graph#1.jpeg") if os.path.isfile(TEST_PATH): return True else: ImageTools.graph([0, 10], [0, 10], [[(0, 0), (2, 2), (4, 4), (6, 6), (8, 8), (10, 10)], [(0, 5), (2, 5), (3, 5), (4, 7), (5, 7), (6, 8), (7, 8), (8, 10), (10, 10)], [(3, 3), (6, 6), (9, 9), (9, 6), (10, 3)]], title="Test Example without Numpy Linspace", y_title="Y Axis", x_title="X Axis", labels=["line#1", "line#2", "line#3"], image_name="Graph#1", include_legend=True) shutil.move(SRC_PATH, DEST_PATH) assert os.path.isfile(TEST_PATH) == True
def test_lingraph(): DEST_PATH = os.path.abspath('./docs/test_utils/result_images') SRC_PATH = os.path.join(os.path.abspath('.'), "Linspace_Graph.png") TEST_PATH = os.path.join(DEST_PATH, "Linspace_Graph.png") if os.path.isfile(TEST_PATH): return True else: ImageTools.graph(with_linspace=True, lin_start=10, lin_end=100, lin_num=150, lin_quadratic=True, lin_cubic=True, labels=["Lin linear", "Lin Quadratic", "Lin Cubic"], include_legend=True, title="Graph with Numpy Linspace", y_title="Y axis", x_title="X axis", image_extension=".png", image_name="Linspace_Graph") shutil.move(SRC_PATH, DEST_PATH) assert os.path.isfile(TEST_PATH) == True
def binary(): # first initializes the Image tools class test_image = ImageTools(TEST_IMAGE_DIR) # finally, calls the binary property test_bin = test_image.binary return test_bin
def path(): # first initializes the Image tools class test_image = ImageTools(TEST_IMAGE_DIR) # finally, calls the path property test_path = test_image.path() return test_path
def size(): # first initializes the Image tools class test_image = ImageTools(TEST_IMAGE_DIR) # finally, calls the size property test_size = test_image.size return test_size
def name(): # first initializes the Imagetools class test_image = ImageTools(TEST_IMAGE_DIR) # finally, calls the name property test_name = test_image.name return test_name
def ext(): # first initializes the Imagetools class test_image = ImageTools(TEST_IMAGE_DIR) # finally, calls the format property test_format = test_image.format return test_format
def height(): # first initializes the Imagetools class test_image = ImageTools(TEST_IMAGE_DIR) # finally, calls the height property test_height = test_image.height return test_height
def float_array(): test_image = ImageTools(TEST_IMAGE_DIR) array = test_image.asarray(np.dtype(np.float)) return array
def int8_array(): test_image = ImageTools(TEST_IMAGE_DIR) array = test_image.asarray(np.dtype(np.int8)) return array
def default_array(): test_image = ImageTools(TEST_IMAGE_DIR) array = test_image.asarray() return array
def file_exts(): # Skips initialization as image is not needed and calls the available_exts property extensions = ImageTools.available_ext() return extensions