- crop_left, crop_bottom, crop_right, crop_top = [float(x) for x in args.crop_range.split(',')]
-cropped_width = a4_width - crop_left - crop_right
-cropped_height = a4_height - crop_bottom - crop_top
-zoom = 1
-if args.crop_range:
- zoom_horizontal = a4_width / (a4_width - crop_left - crop_right)
- zoom_vertical = a4_height / (a4_height - crop_bottom - crop_top)
- if (zoom_horizontal > 1 and zoom_vertical < 1) or (zoom_horizontal < 1 and zoom_vertical > 1):
- print("Error: opposing zooms.")
- exit(1)
- elif zoom_horizontal + zoom_vertical > 2:
- zoom = min(zoom_horizontal, zoom_vertical)
- else:
- zoom = max(zoom_horizontal, zoom_vertical)
+ for crop_range in args.crop_range:
+ initial_split = crop_range.split(':')
+ if len(initial_split) > 1:
+ page_range = initial_split[0]
+ crops = initial_split[1]
+ else:
+ page_range = None
+ crops = initial_split[0]
+ start_page, end_page = parse_page_range(page_range, pages_to_add)
+ crop_left, crop_bottom, crop_right, crop_top = [float(x) for x in crops.split(',')]
+ cropped_width = a4_width - crop_left - crop_right
+ cropped_height = a4_height - crop_bottom - crop_top
+ zoom = 1
+ zoom_horizontal = a4_width / (a4_width - crop_left - crop_right)
+ zoom_vertical = a4_height / (a4_height - crop_bottom - crop_top)
+ if (zoom_horizontal > 1 and zoom_vertical < 1) or (zoom_horizontal < 1 and zoom_vertical > 1):
+ print("Error: opposing zooms.")
+ exit(1)
+ elif zoom_horizontal + zoom_vertical > 2:
+ zoom = min(zoom_horizontal, zoom_vertical)
+ else:
+ zoom = max(zoom_horizontal, zoom_vertical)
+ for page_num in range(start_page, end_page):
+ crops_at_page[page_num] = (crop_left, crop_bottom, crop_right, crop_top)
+ zoom_at_page[page_num] = zoom