mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove IM from the book editor
This commit is contained in:
parent
af51493118
commit
f1af9c9f6d
@ -6,8 +6,10 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
|
||||
from calibre import as_unicode
|
||||
from calibre.utils.magick import Image
|
||||
from calibre.ebooks.oeb.polish.check.base import BaseError, WARN
|
||||
from calibre.ebooks.oeb.polish.check.parsing import EmptyFile
|
||||
|
||||
@ -51,14 +53,12 @@ def check_raster_images(name, mt, raw):
|
||||
if not raw:
|
||||
return [EmptyFile(name)]
|
||||
errors = []
|
||||
i = Image()
|
||||
try:
|
||||
i.load(raw)
|
||||
i = Image.open(BytesIO(raw))
|
||||
except Exception as e:
|
||||
errors.append(InvalidImage(as_unicode(e.message), name))
|
||||
else:
|
||||
if i.colorspace == 'CMYKColorspace':
|
||||
if i.mode == 'CMYK':
|
||||
errors.append(CMYKImage(_('Image is in the CMYK colorspace'), name))
|
||||
|
||||
return errors
|
||||
|
||||
|
@ -11,7 +11,7 @@ import shutil, re, os
|
||||
|
||||
from calibre.ebooks.oeb.base import OPF, OEB_DOCS, XPath, XLINK, xml2text
|
||||
from calibre.ebooks.oeb.polish.replace import replace_links, get_recommended_folders
|
||||
from calibre.utils.magick.draw import identify, identify_data
|
||||
from calibre.utils.imghdr import identify
|
||||
|
||||
def set_azw3_cover(container, cover_path, report, options=None):
|
||||
existing_image = options is not None and options.get('existing_image', False)
|
||||
@ -299,9 +299,10 @@ def create_epub_cover(container, cover_path, existing_image, options=None):
|
||||
width, height = 600, 800
|
||||
try:
|
||||
if existing_image:
|
||||
width, height = identify_data(container.raw_data(existing_image, decode=False))[:2]
|
||||
width, height = identify(container.raw_data(existing_image, decode=False))[1:]
|
||||
else:
|
||||
width, height = identify(cover_path)[:2]
|
||||
with lopen(cover_path, 'rb') as csrc:
|
||||
width, height = identify(csrc)[1:]
|
||||
except:
|
||||
container.log.exception("Failed to get width and height of cover")
|
||||
ar = 'xMidYMid meet' if keep_aspect else 'none'
|
||||
|
@ -15,7 +15,7 @@ from calibre.ebooks.oeb.base import XPath, xml2text
|
||||
from calibre.ebooks.oeb.polish.container import OEB_DOCS, OEB_STYLES, OEB_FONTS
|
||||
from calibre.ebooks.oeb.polish.spell import get_all_words
|
||||
from calibre.utils.icu import numeric_sort_key, ord_string, safe_chr
|
||||
from calibre.utils.magick.draw import identify
|
||||
from calibre.utils.imghdr import identify
|
||||
from css_selectors import Select, SelectorError
|
||||
|
||||
File = namedtuple('File', 'name dir basename size category')
|
||||
@ -50,7 +50,7 @@ def safe_img_data(container, name, mt):
|
||||
if 'svg' in mt:
|
||||
return 0, 0
|
||||
try:
|
||||
width, height, fmt = identify(container.name_to_abspath(name))
|
||||
fmt, width, height = identify(container.name_to_abspath(name))
|
||||
except Exception:
|
||||
width = height = 0
|
||||
return width, height
|
||||
|
Loading…
x
Reference in New Issue
Block a user