From 41ce07ea7ab5947e604cdecfb3db46f04a37308d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Oct 2014 09:08:09 +0530 Subject: [PATCH] AZW3 Input: Fix crash when processing AZW3 files that contain certain SVG images dies to a bug in ImageMagick. See #1384375 (svg cover lost when converting ePub->AZW3) --- src/calibre/utils/imghdr.py | 10 ++++++++-- src/calibre/utils/magick/draw.py | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/imghdr.py b/src/calibre/utils/imghdr.py index 0179ad5bbc..54ec8209a5 100644 --- a/src/calibre/utils/imghdr.py +++ b/src/calibre/utils/imghdr.py @@ -10,10 +10,10 @@ def what(file, h=None): if h is None: if isinstance(file, basestring): f = open(file, 'rb') - h = f.read(44) + h = f.read(150) else: location = file.tell() - h = file.read(44) + h = file.read(150) file.seek(location) f = None else: @@ -132,6 +132,12 @@ def test_emf(h, f): tests.append(test_emf) +def test_svg(h, f): + if (h[:2] == b'