diff --git a/argv.py b/argv.py
index f29c9cb..801b6e1 100644
--- a/argv.py
+++ b/argv.py
@@ -78,7 +78,7 @@ class ArgvParser:
ArgvParser.parser.error("--steps requires --altered.")
elif a.steps and a.altered:
if not os.path.isdir(a.altered):
- ArgvParser.parser.error("{} directory doesn't exist.".format(a.input))
+ ArgvParser.parser.error("{} directory doesn't exist.".format(a.altered))
def config_all(a):
config_checkpoints(a)
@@ -145,12 +145,12 @@ class ArgvParser:
"-d", "--debug", action="store_true", help="Enable log debug mod."
)
ArgvParser.parser.add_argument(
- "-i", "--input", help="Path of the photo to transform."
+ "-i", "--input", help="Path of the photo or directory to transform ."
)
ArgvParser.parser.add_argument(
- "-o",
- "--output",
- help="Path where the transformed photo will be saved. Default : output.",
+ "-o", "--output",
+ help="Path of the file or the directory where the transformed photo(s)"
+ "will be saved. Default : output",
)
processing_mod = ArgvParser.parser.add_mutually_exclusive_group()
processing_mod.add_argument(
diff --git a/processing/__init__.py b/processing/__init__.py
index c189160..d523a5d 100644
--- a/processing/__init__.py
+++ b/processing/__init__.py
@@ -130,10 +130,14 @@ class ImageTransform(Process):
conf.log.debug("All Phases : {}".format(self.__phases))
conf.log.debug("To Be Executed Phases : {}".format(self.__phases[self.__starting_step:self.__ending_step]))
+ path = self.__altered_path if os.path.isfile(self._args['input']) or not self._args.get('folder_altered') \
+ else os.path.join(self._args['folder_altered'], os.path.basename(self.__output_path))
+
self.__image_steps = [input_path] + [
- os.path.join(self.__altered_path, "{}.png".format(p.__class__.__name__))
+ os.path.join(path, "{}.png".format(p().__class__.__name__))
for p in self.__phases[:self.__starting_step]
]
+ conf.log.debug(self.__image_steps)
def _info_start_run(self):
super()._info_start_run()
@@ -155,15 +159,19 @@ class ImageTransform(Process):
Execute all phases on the image
:return: None
"""
- for p in (x(args=self._args) for x in self.__phases[len(self.__image_steps) - 1:]):
+ for p in (x(args=self._args) for x in self.__phases[self.__starting_step:self.__ending_step]):
r = p.run(*[self.__image_steps[i] for i in p.input_index])
self.__image_steps.append(r)
if self.__altered_path:
- write_image(r, os.path.join(self.__altered_path, "{}.png".format(p.__class__.__name__)))
- conf.log.debug("{} Step Image Of {} Execution"
- .format(
- os.path.join(self.__altered_path, "{}.png".format(p.__class__.__name__)),
+ path = self.__altered_path \
+ if os.path.isfile(self._args['input']) or not self._args.get('folder_altered') \
+ else os.path.join(self._args['folder_altered'], os.path.basename(self.__output_path))
+
+ write_image(r, os.path.join(path, "{}.png".format(p.__class__.__name__)))
+
+ conf.log.debug("{} Step Image Of {} Execution".format(
+ os.path.join(path, "{}.png".format(p.__class__.__name__)),
camel_case_to_str(p.__class__.__name__),
))
@@ -264,27 +272,34 @@ class FolderImageTransform(MultipleImageTransform):
]
def __get_folder_args(self, folder_path):
+ def add_folder_altered(args):
+ if args['altered']:
+ args['folder_altered'] = os.path.join(args['altered'],
+ pathlib.Path(*pathlib.Path(folder_path).parts[1:]))
+ return args
+
json_path = os.path.join(folder_path, self._args['json_folder_name'])
+
conf.log.debug("Json Path Setting Path: {}".format(json_path))
if not os.path.isfile(json_path):
conf.log.info("No Json File Settings Found In {}. Using Default Configuration. ".format(folder_path))
- return self._args
+ return add_folder_altered(self._args)
try:
with open(json_path, 'r') as f:
json_data = json.load(f)
except JSONDecodeError:
conf.log.info("Json File Settings {} Is Not In Valid JSON Format. Using Default Configuration. "
.format(folder_path))
- return self._args
+ return add_folder_altered(self._args)
try:
a = argv.ArgvParser.config_args(argv.ArgvParser.parser.parse_args(sys.argv[1:]), json_data=json_data)
conf.log.info("Using {} Configuration for processing {} folder. "
.format(json_path, folder_path))
- return a
+ return add_folder_altered(a)
except SystemExit:
conf.log.error("Arguments json file {} contains configuration error. "
"Using Default Configuration".format(json_path))
- return self._args
+ return add_folder_altered(self._args)
class GifTransform(Process):