Relocate example plugin

This commit is contained in:
James R. Barlow
2020-05-07 03:27:39 -07:00
parent 9462f0a28f
commit 7a12908db9
2 changed files with 53 additions and 38 deletions
-38
View File
@@ -1,38 +0,0 @@
import logging
from PIL import Image
from ocrmypdf import hookimpl
log = logging.getLogger(__name__)
@hookimpl
def add_options(parser):
parser.add_argument('--grayscale-ocr', action='store_true')
@hookimpl
def prepare(options):
pass
@hookimpl
def validate(pdfinfo, options):
pass
@hookimpl
def filter_ocr_image(page, image):
if page.options.grayscale_ocr:
log.info("graying")
return image.convert('L')
return image
@hookimpl
def filter_page_image(page, image_filename):
output = image_filename.with_suffix('.jpg')
with Image.open(image_filename) as im:
im.save(output)
return output