mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove IM from PDF Input
This commit is contained in:
parent
26c399100d
commit
869b771320
@ -151,14 +151,12 @@ def parse_outline(raw, output_dir):
|
||||
|
||||
|
||||
def flip_image(img, flip):
|
||||
from calibre.utils.magick import Image
|
||||
im = Image()
|
||||
im.open(img)
|
||||
if b'x' in flip:
|
||||
im.flip(True)
|
||||
if b'y' in flip:
|
||||
im.flip()
|
||||
im.save(img)
|
||||
from calibre.utils.img import flip_image, image_and_format_from_data, image_to_data
|
||||
with lopen(img, 'r+b') as f:
|
||||
img, fmt = image_and_format_from_data(f.read())
|
||||
img = flip_image(img, horizontal=b'x' in flip, vertical=b'y' in flip)
|
||||
f.seek(0), f.truncate()
|
||||
f.write(image_to_data(img, fmt=fmt))
|
||||
|
||||
def flip_images(raw):
|
||||
for match in re.finditer(b'<IMG[^>]+/?>', raw, flags=re.I):
|
||||
|
@ -188,6 +188,9 @@ class Canvas(object):
|
||||
def export(self, fmt='JPEG', compression_quality=95):
|
||||
return image_to_data(self.img, compression_quality=compression_quality, fmt=fmt)
|
||||
|
||||
def flip_image(img, horizontal=False, vertical=False):
|
||||
return image_from_data(img).mirrored(horizontal, vertical)
|
||||
|
||||
def run_optimizer(file_path, cmd, as_filter=False, input_data=None):
|
||||
file_path = os.path.abspath(file_path)
|
||||
cwd = os.path.dirname(file_path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user