Upgrade pre-commit and associated tools; various lints
This commit is contained in:
@@ -24,14 +24,12 @@ from ocrmypdf.exceptions import MissingDependencyError, SubprocessOutputError
|
||||
from ocrmypdf.helpers import Resolution
|
||||
from ocrmypdf.subprocess import get_version, run, run_polling_stderr
|
||||
|
||||
# Remove this workaround when we require Pillow >= 10
|
||||
try:
|
||||
ROTATE_90 = Image.Transpose.ROTATE_90
|
||||
ROTATE_180 = Image.Transpose.ROTATE_180
|
||||
ROTATE_270 = Image.Transpose.ROTATE_270
|
||||
Transpose = Image.Transpose # type: ignore
|
||||
except AttributeError:
|
||||
ROTATE_90 = Image.ROTATE_90
|
||||
ROTATE_180 = Image.ROTATE_180
|
||||
ROTATE_270 = Image.ROTATE_270
|
||||
# Pillow 9 shim
|
||||
Transpose = Image # type: ignore
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -47,7 +45,7 @@ For details see:
|
||||
"""
|
||||
|
||||
# Most reliable what to get the bitness of Python interpreter, according to Python docs
|
||||
_is_64bit = sys.maxsize > 2 ** 32
|
||||
_is_64bit = sys.maxsize > 2**32
|
||||
|
||||
_gswin = None
|
||||
if os.name == 'nt':
|
||||
@@ -141,11 +139,11 @@ def rasterize_pdf(
|
||||
# rotation is a clockwise angle and Image.ROTATE_* is
|
||||
# counterclockwise so this cancels out the rotation
|
||||
if rotation == 90:
|
||||
im = im.transpose(ROTATE_90)
|
||||
im = im.transpose(Transpose.ROTATE_90)
|
||||
elif rotation == 180:
|
||||
im = im.transpose(ROTATE_180)
|
||||
im = im.transpose(Transpose.ROTATE_180)
|
||||
elif rotation == 270:
|
||||
im = im.transpose(ROTATE_270)
|
||||
im = im.transpose(Transpose.ROTATE_270)
|
||||
if rotation % 180 == 90:
|
||||
page_dpi = page_dpi.flip_axis()
|
||||
im.save(fspath(output_file), dpi=page_dpi)
|
||||
|
||||
Reference in New Issue
Block a user