mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 09:23:14 +02:00
Remove IM from PDF Input
This commit is contained in:
parent
26c399100d
commit
869b771320
2 changed files with 9 additions and 8 deletions
|
|
@ -151,14 +151,12 @@ def process_node(node, toc):
|
|||
|
||||
|
||||
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 @@ def compose(self, img, x=0, y=0):
|
|||
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…
Reference in a new issue