Ejemplo n.º 1
0
def _color_overlay_handler(img_paths, color, opacity, write=True):
	import pyifx.misc as misc
	if type(img_paths) == misc.ImageVolume:
		if not os.path.exists(img_paths.get_output_path()):
			os.makedirs(img_paths.get_output_path())

		new_vol = misc.ImageVolume(img_paths.get_input_path(), img_paths.get_output_path(), img_paths.get_prefix(), img_paths.convert)
		new_vol.set_volume([])

		for img in img_paths.get_volume():
			new_vol.volume.append(_color_overlay_operation(img, color, opacity, write=write))

		return new_vol

	elif type(img_paths) == misc.PyifxImage:
		return _color_overlay_operation(img_paths, color, opacity, write=write)

	elif type(img_paths) == list:
		new_imgs = []
		for img in img_paths:
			if type(img) != misc.PyifxImage:
				raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")

			new_imgs.append(_color_overlay_operation(img, color, opacity, write=write))
		return new_imgs

	else:
		raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")
Ejemplo n.º 2
0
def _rewrite_file_handler(img_paths):
	import pyifx.misc as misc
	if type(img_paths) == misc.ImageVolume:

		if not os.path.exists(img_paths.get_output_path()):
			os.makedirs(img_paths.get_output_path())

		new_vol = misc.ImageVolume(img_paths.get_input_path(), img_paths.get_output_path(), img_paths.get_prefix(), img_paths.convert)
		new_vol.set_volume([])

		for img in img_paths.get_volume():
			new_vol.volume.append(_write_file(img_paths))

		return new_vol

	elif type(img_paths) == misc.PyifxImage:
		return _write_file(img_paths)

	elif type(img_paths) == list:
		new_imgs = []

		for img in img_paths:

			if type(img) != misc.PyifxImage:
				raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")

			new_imgs.append(_write_file(img))

		return new_imgs

	else:
		raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")
Ejemplo n.º 3
0
def _brightness_handler(img_paths, percent, method, write=True):
	import pyifx.misc as misc
	if type(img_paths) == misc.ImageVolume:

		if not os.path.exists(img_paths.get_output_path()):
			os.makedirs(img_paths.get_output_path())

		new_vol = misc.ImageVolume(img_paths.get_input_path(), img_paths.get_output_path(), img_paths.get_prefix(), img_paths.convert)
		new_vol.set_volume([])

		for img in img_paths.get_volume():
			if method == "b" or method == "d":
				new_vol.volume.append(_brightness_operation(img, percent, method, write=write))
			else:
				raise Exception("An internal error occurred.")

		return new_vol

	elif type(img_paths) == misc.PyifxImage:
			if method == "b" or method == "d":
				return _brightness_operation(img_paths, percent, method, write=write)
			else:
				raise Exception("An internal error occurred.")

	elif type(img_paths) == list:
		new_imgs = []

		for img in img_paths:
			if type(img) != misc.PyifxImage:
				raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")
			if method == "b" or method == "d":
				new_imgs.append(_brightness_operation(img, percent, method, write=write))
			else:
				raise Exception("Something went wrong.")
		return new_imgs

	else:
		raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")
Ejemplo n.º 4
0
def _convolution_handler(img_paths, radius, type_kernel, size, custom=None, write=True):
	import pyifx.misc as misc

	kernel = _create_kernel(radius, type_kernel, size, custom=custom)	

	if type(img_paths) == misc.ImageVolume:

		if not os.path.exists(img_paths.get_output_path()):
			os.makedirs(img_paths.get_output_path())

		new_vol = misc.ImageVolume(img_paths.get_input_path(), img_paths.get_output_path(), img_paths.get_prefix(), img_paths.convert)
		new_vol.set_volume([])

		for img in img_paths.get_volume():
			new_vol.volume.append(_convolution_operation(img, kernel, write=write))

		return new_vol

	elif type(img_paths) == misc.PyifxImage:
		return _convolution_operation(img_paths, kernel, write=write)

	elif type(img_paths) == list:

		new_imgs = []

		for img in img_paths:

			if type(img) != misc.PyifxImage:
				raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")

			new_imgs.append(_convolution_operation(img, kernel, write=write))

		return new_imgs

	else:
		raise TypeError("Invalid type used: Input contains non-Pyifx images and/or classes.")