mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix img flip regression in PDF
PDF Input: Fix a regression that caused some images to be flipped when converting PDF files that use image rotation operators. See #1201083
This commit is contained in:
parent
34abccc4f1
commit
9ec8aac3f4
@ -118,7 +118,7 @@ def flip_image(img, flip):
|
|||||||
im.save(img)
|
im.save(img)
|
||||||
|
|
||||||
def flip_images(raw):
|
def flip_images(raw):
|
||||||
for match in re.finditer(b'<IMG[^>]+/?>', raw):
|
for match in re.finditer(b'<IMG[^>]+/?>', raw, flags=re.I):
|
||||||
img = match.group()
|
img = match.group()
|
||||||
m = re.search(br'class="(x|y|xy)flip"', img)
|
m = re.search(br'class="(x|y|xy)flip"', img)
|
||||||
if m is None: continue
|
if m is None: continue
|
||||||
@ -127,7 +127,6 @@ def flip_images(raw):
|
|||||||
if src is None: continue
|
if src is None: continue
|
||||||
img = src.group(1)
|
img = src.group(1)
|
||||||
if not os.path.exists(img): continue
|
if not os.path.exists(img): continue
|
||||||
print ('Flipping image %s: %s'%(img, flip))
|
|
||||||
flip_image(img, flip)
|
flip_image(img, flip)
|
||||||
raw = re.sub(br'<STYLE.+?</STYLE>\s*', b'', raw, flags=re.I|re.DOTALL)
|
raw = re.sub(br'<STYLE.+?</STYLE>\s*', b'', raw, flags=re.I|re.DOTALL)
|
||||||
return raw
|
return raw
|
||||||
|
Loading…
x
Reference in New Issue
Block a user