p=ArgumentParser(description='Script converts 8 images (jpg or png) from a given directory into a single page 4x2 imposition. Example: python imposition.py --dir imgs/ --size a3 --order random ')
p.add_argument("--dir",metavar='',default='',required=True,help="Image directory, which stores the source images for the imposition")
p.add_argument("--size",metavar='',default="A4",choices=['A4','a4','A3','a3'],help="Size of the printing sheet: A4 or A3. Default:A4")
p.add_argument("--pages",metavar='',type=int,choices=[1,2],default=1,help="Number of imposition pages. Default:1. Currently only 1 or 2 pages impositions are available.")
p.add_argument("--order",metavar='',default="alphabet",choices=["alphabet","reverse","random"],help="Image distribution Order in the imposition. Possible Values: alphabet (alphabetically) , reverse (reverse alphabetically), random. Default: alphabet")
p.add_argument("--output",metavar='',default="output.pdf",help="Output file. Can either be a pdf, jpg or png. Default: output.pdf")
args=p.parse_args()
printargs
temp_dir=tempfile.mkdtemp()
# dimensions
@ -43,10 +44,15 @@ elif args.order == 'random':
shuffle(listdir)
listdir_order=listdir
printlistdir_order
listdir_order=listdir_order[0:8]
pagenumbers=[2,5,4,3,1,6,7,0]# from from top left to bottom right ( order in imagemagick creates mosaic)
listdir_order=[listdir_order[n]forninpagenumbers]# reorder according to pagenumbers
# print listdir_order
ifargs.pages==1:
listdir_order=listdir_order[0:8]
pagenumbers=[2,5,4,3,1,6,7,0]# from from top left to bottom right ( order in imagemagick creates mosaic)