EPUB Output: Auto convert CMYK images to RGB

Works around Adobe Digital Editions inablity to display CMYK images.
See #1246710 (Frontpage is not apearing in the readerprogram)
This commit is contained in:
Kovid Goyal 2013-11-03 11:43:51 +05:30
parent 6a14af6f99
commit 9b71d8ed9e

View File

@ -53,9 +53,21 @@ class RescaleImages(object):
try:
if self.check_colorspaces and img.colorspace == 'CMYKColorspace':
# We cannot do an automatic conversion of CMYK to RGB as
# We cannot do an imagemagick conversion of CMYK to RGB as
# ImageMagick inverts colors if you just set the colorspace
# to rgb. See for example: https://bugs.launchpad.net/bugs/1246710
from PyQt4.Qt import QImage
from calibre.gui2 import pixmap_to_data
qimg = QImage()
qimg.loadFromData(raw)
if not qimg.isNull():
raw = item.data = pixmap_to_data(qimg, format=ext, quality=95)
img = Image()
img.load(raw)
self.log.warn(
'The image %s is in the CMYK colorspace, converting it '
'to RGB as Adobe Digital Editions cannot display CMYK' % item.href)
else:
self.log.warn(
'The image %s is in the CMYK colorspace, you should convert'
' it to sRGB as Adobe Digital Editions cannot render CMYK' % item.href)