mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-03-18 15:37:52 -04:00
...
This commit is contained in:
parent
3ef90d6a36
commit
febe7080e6
@ -32,8 +32,10 @@ class CMYKImage(BaseError):
|
||||
level = WARN
|
||||
|
||||
def __call__(self, container):
|
||||
from qt.core import QImage
|
||||
|
||||
from calibre.gui2 import pixmap_to_data
|
||||
from calibre.utils.img import image_from_data
|
||||
from calibre_extensions.imageops import load_from_data_without_gil
|
||||
ext = container.mime_map[self.name].split('/')[-1].upper()
|
||||
if ext == 'JPG':
|
||||
ext = 'JPEG'
|
||||
@ -41,7 +43,8 @@ class CMYKImage(BaseError):
|
||||
return False
|
||||
with container.open(self.name, 'r+b') as f:
|
||||
raw = f.read()
|
||||
i = image_from_data(raw)
|
||||
i = QImage()
|
||||
load_from_data_without_gil(i, raw)
|
||||
if i.isNull():
|
||||
return False
|
||||
raw = pixmap_to_data(i, format=ext, quality=95)
|
||||
|
||||
@ -47,10 +47,10 @@ from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.config import device_prefs, prefs, tweaks
|
||||
from calibre.utils.date import UNDEFINED_DATE, dt_factory, is_date_undefined, qt_from_dt, qt_to_dt
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.img import image_from_data
|
||||
from calibre.utils.localization import calibre_langcode_to_name, ngettext
|
||||
from calibre.utils.resources import get_path as P
|
||||
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
||||
from calibre_extensions.imageops import load_from_data_without_gil
|
||||
|
||||
Counts = namedtuple('Counts', 'library_total total current')
|
||||
|
||||
@ -882,7 +882,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
|
||||
if not data:
|
||||
return self.default_image
|
||||
img = image_from_data(data)
|
||||
img = QImage()
|
||||
load_from_data_without_gil(img, data)
|
||||
return self.default_image if img.isNull() else img
|
||||
|
||||
def build_data_convertors(self):
|
||||
@ -1785,9 +1786,9 @@ class DeviceBooksModel(BooksModel): # {{{
|
||||
img.load(cdata.image_path)
|
||||
elif cdata:
|
||||
if isinstance(cdata, (tuple, list)):
|
||||
img = image_from_data(cdata[-1])
|
||||
load_from_data_without_gil(img, cdata[-1])
|
||||
else:
|
||||
img = image_from_data(cdata)
|
||||
load_from_data_without_gil(img, cdata)
|
||||
if img.isNull():
|
||||
img = self.default_image
|
||||
return img
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user