def convert_images(images, outfile, paper_width, paper_height, transform=False): for i, (img, filename, page) in enumerate(opencv.iter_images_and_pages(images)): img = opencv.ensure_portrait(img) img = opencv.sharpen(img) if transform: try: img = opencv.transform_using_corners(img, paper_width, paper_height) except AssertionError: log.error(_("Could not apply 3D-transformation to image '%s', page %i!") % (filename, page)) mono = opencv.convert_to_monochrome(img) image.write_a1_to_tiff(outfile, opencv.to_a1_surf(mono))
def convert_images(images, outfile, paper_width, paper_height, transform=False): portrait = paper_height >= paper_width for i, (img, filename, page) in enumerate(opencv.iter_images_and_pages(images)): img = opencv.ensure_orientation(img, portrait) img = opencv.sharpen(img) if transform: try: img = opencv.transform_using_corners(img, paper_width, paper_height) except AssertionError: log.warning(_("Could not apply 3D-transformation to image '%s', page %i!") % (filename, page)) mono = opencv.convert_to_monochrome(img) image.write_a1_to_tiff(outfile, opencv.to_a1_surf(mono))