mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
RTF Input: Fix some WMF images embedded in RTF files being distorted on conversion. Fixes #934167 (Enhancement to convert pictures in rtf files)
This commit is contained in:
parent
553ae3f8ac
commit
ccffbd6715
@ -246,6 +246,19 @@ class WMF(object):
|
|||||||
def to_png(self):
|
def to_png(self):
|
||||||
bmps = list(sorted(self.bitmaps, key=lambda x: len(x)))
|
bmps = list(sorted(self.bitmaps, key=lambda x: len(x)))
|
||||||
bmp = bmps[-1]
|
bmp = bmps[-1]
|
||||||
|
|
||||||
|
# ImageMagick does not convert some bmp files correctly, while Qt does,
|
||||||
|
# so try Qt first. See for instance:
|
||||||
|
# https://bugs.launchpad.net/calibre/+bug/934167
|
||||||
|
from PyQt4.Qt import QImage, QByteArray, QBuffer
|
||||||
|
i = QImage()
|
||||||
|
if i.loadFromData(bmp):
|
||||||
|
ba = QByteArray()
|
||||||
|
buf = QBuffer(ba)
|
||||||
|
buf.open(QBuffer.WriteOnly)
|
||||||
|
i.save(buf, 'png')
|
||||||
|
return bytes(ba.data())
|
||||||
|
|
||||||
from calibre.utils.magick import Image
|
from calibre.utils.magick import Image
|
||||||
img = Image()
|
img = Image()
|
||||||
img.load(bmp)
|
img.load(bmp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user