mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
AZW3 Input: Do not fail to identify JPEG images with BIM headers created with Adobe Photoshop. Fixes #1167985 (Private bug)
This commit is contained in:
parent
de663280c2
commit
891b73c785
@ -51,9 +51,11 @@ def reverse_tag_iter(block):
|
|||||||
end = len(block)
|
end = len(block)
|
||||||
while True:
|
while True:
|
||||||
pgt = block.rfind(b'>', 0, end)
|
pgt = block.rfind(b'>', 0, end)
|
||||||
if pgt == -1: break
|
if pgt == -1:
|
||||||
|
break
|
||||||
plt = block.rfind(b'<', 0, pgt)
|
plt = block.rfind(b'<', 0, pgt)
|
||||||
if plt == -1: break
|
if plt == -1:
|
||||||
|
break
|
||||||
yield block[plt:pgt+1]
|
yield block[plt:pgt+1]
|
||||||
end = plt
|
end = plt
|
||||||
|
|
||||||
@ -231,12 +233,12 @@ class Mobi8Reader(object):
|
|||||||
flowpart = self.flows[j]
|
flowpart = self.flows[j]
|
||||||
nstr = '%04d' % j
|
nstr = '%04d' % j
|
||||||
m = svg_tag_pattern.search(flowpart)
|
m = svg_tag_pattern.search(flowpart)
|
||||||
if m != None:
|
if m is not None:
|
||||||
# svg
|
# svg
|
||||||
typ = 'svg'
|
typ = 'svg'
|
||||||
start = m.start()
|
start = m.start()
|
||||||
m2 = image_tag_pattern.search(flowpart)
|
m2 = image_tag_pattern.search(flowpart)
|
||||||
if m2 != None:
|
if m2 is not None:
|
||||||
format = 'inline'
|
format = 'inline'
|
||||||
dir = None
|
dir = None
|
||||||
fname = None
|
fname = None
|
||||||
@ -406,6 +408,10 @@ class Mobi8Reader(object):
|
|||||||
else:
|
else:
|
||||||
imgtype = what(None, data)
|
imgtype = what(None, data)
|
||||||
if imgtype is None:
|
if imgtype is None:
|
||||||
|
from calibre.utils.magick.draw import identify_data
|
||||||
|
try:
|
||||||
|
imgtype = identify_data(data)[2]
|
||||||
|
except Exception:
|
||||||
imgtype = 'unknown'
|
imgtype = 'unknown'
|
||||||
href = 'images/%05d.%s'%(fname_idx, imgtype)
|
href = 'images/%05d.%s'%(fname_idx, imgtype)
|
||||||
with open(href.replace('/', os.sep), 'wb') as f:
|
with open(href.replace('/', os.sep), 'wb') as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user