Skip to content

Commit

Permalink
--
Browse files Browse the repository at this point in the history
  • Loading branch information
soeren-kirchner committed Nov 8, 2019
1 parent 5576011 commit 6582159
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/pyimgbatch-short.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"comment": "some sample pictures",
"source": "webset/source",
"dest": "webset/dest",
"prefix": "default-prefix.",
"prefix": "web.",
"configs": [
{ "width": 180, "suffix": ".w180", "webset": "@3x" },
{ "width": 300, "suffix": ".w400", "webset": "@3x" },
{ "width": 300, "suffix": ".w300", "webset": "@3x" },
{ "width": 400, "suffix": ".w400", "webset": "@3x" },
{ "height": 800, "prefix": "preview.", "webset": "@3x" }
]
Expand Down
2 changes: 1 addition & 1 deletion examples/pyimgbatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"prefix": "web.",
"configs": [
{ "width": 180, "suffix": ".w180", "webset": "@3x" },
{ "width": 300, "suffix": ".w400", "webset": "@3x" },
{ "width": 300, "suffix": ".w300", "webset": "@3x" },
{ "width": 400, "suffix": ".w400", "webset": "@3x" },
{ "height": 800, "prefix": "preview.", "webset": "@3x" }
]
Expand Down
14 changes: 11 additions & 3 deletions pyimgbatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ def main():
args = get_args()
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)

logging.debug(args)
pib = PyImgBatch(vars(args))

pib = PyImgBatch(prepare_arguments(args))
pib.exec()


def prepare_arguments(args):
args_prep = vars(args)
args_prep['subfolder'] = not args_prep['nosubfolder']
return args_prep


def get_args():
parser = argparse.ArgumentParser()

file_handling_group = parser.add_argument_group('file handling')
file_handling_group.add_argument('-c', '--configfile', type=str,
default='imagebatch.json', help='configuration file')
default='imagebatch.json', help='configuration file') # TODO: remove
file_handling_group.add_argument('-p', '--project', type=str,
default='pyimagebatch.json', help='configuration file')
file_handling_group.add_argument('-s', '--source', type=str,
Expand All @@ -34,6 +40,8 @@ def get_args():
help='destination folder for the processed images')
file_handling_group.add_argument('-o', '--override', action='store_true',
default=False, help='overrides existing files')
file_handling_group.add_argument('--nosubfolder', action='store_true',
default=False, help='overrides existing files')

output_group = parser.add_argument_group('output / user interaction')
output_group.add_argument('--no-progress', action='store_true',
Expand Down
2 changes: 1 addition & 1 deletion pyimgbatch/pyimgbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def ext(self):

@property
def with_subfolder(self):
return self._value(CONFKEY.WEBSETADDON, '')
return self._value(CONFKEY.SUBFOLDER, False)

@property
def destination_size(self):
Expand Down

0 comments on commit 6582159

Please sign in to comment.