diff --git a/process b/process index b9785d97..3f202dcc 100755 --- a/process +++ b/process @@ -94,6 +94,7 @@ def transform(config, root_folder): ): if not os.path.exists(os.path.join(root_folder, path)): os.makedirs(os.path.join(root_folder, path)) + count = 0 for img in config['images']: shutil.copyfile(os.path.join(root_folder, img), os.path.join(root_folder, 'process', os.path.basename(img))) img = os.path.join(root_folder, 'process', os.path.basename(img)) @@ -151,6 +152,26 @@ def transform(config, root_folder): print("Ignore image with no content: {}".format(img)) continue + try: + w, h = [int(e) for e in output(convert + [img, '-format', '%w %h', 'info:-']).strip().split(b' ')] + folder = os.path.join(root_folder, 'auto-split') + if not os.path.exists(folder): + os.makedirs(folder) + + count += 1 + call(convert + [ + '-crop', '{}x{}+0+0'.format(w / 2, h), + img, os.path.join(folder, 'image-{}.png'.format(count)) + ]) + count += 1 + call(convert + [ + '-crop', '{}x{}+{}+0'.format(w / 2, h, w / 2), + img, os.path.join(folder, 'image-{}.png'.format(count)) + ]) + + except Exception as e: + print('error: ' + e) + call([ 'scantailor-cli', '--dpi=300', '--content-detection=normal', '--output-dpi=300', '--color-mode=color_grayscale',