mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix extra 1x1 unused GIF image being created when saving and re-opening AZW3 files. Fixes #1272410 [Editing AZW3 book adds 1x1 pixel gray gif each time](https://bugs.launchpad.net/calibre/+bug/1272410)
This commit is contained in:
parent
a36aa7dab9
commit
a9b3adbad3
@ -386,6 +386,7 @@ class Mobi8Reader(object):
|
|||||||
return build_toc(index_entries)
|
return build_toc(index_entries)
|
||||||
|
|
||||||
def extract_resources(self):
|
def extract_resources(self):
|
||||||
|
from calibre.ebooks.mobi.writer2.resources import PLACEHOLDER_GIF
|
||||||
resource_map = []
|
resource_map = []
|
||||||
for x in ('fonts', 'images'):
|
for x in ('fonts', 'images'):
|
||||||
os.mkdir(x)
|
os.mkdir(x)
|
||||||
@ -414,6 +415,8 @@ class Mobi8Reader(object):
|
|||||||
if font['encrypted']:
|
if font['encrypted']:
|
||||||
self.encrypted_fonts.append(href)
|
self.encrypted_fonts.append(href)
|
||||||
else:
|
else:
|
||||||
|
if len(data) == len(PLACEHOLDER_GIF) and data == PLACEHOLDER_GIF:
|
||||||
|
continue
|
||||||
imgtype = what(None, data)
|
imgtype = what(None, data)
|
||||||
if imgtype is None:
|
if imgtype is None:
|
||||||
from calibre.utils.magick.draw import identify_data
|
from calibre.utils.magick.draw import identify_data
|
||||||
|
@ -14,7 +14,7 @@ from calibre.ebooks import generate_masthead
|
|||||||
from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES
|
from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES
|
||||||
from calibre.utils.imghdr import what
|
from calibre.utils.imghdr import what
|
||||||
|
|
||||||
PLACEHOLDER_GIF = b'GIF89a\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\xff\xff\xff!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00@\x02\x01D\x00;'
|
PLACEHOLDER_GIF = b'GIF89a\x01\x00\x01\x00\xf0\x00\x00\x00\x00\x00\xff\xff\xff!\xf9\x04\x01\x00\x00\x00\x00!\xfe calibre-placeholder-gif-for-azw3\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;' # noqa
|
||||||
|
|
||||||
class Resources(object):
|
class Resources(object):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user