mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove IM from icon theme creation
This commit is contained in:
parent
416c94e159
commit
e25d1220f3
@ -17,7 +17,7 @@ from PyQt5.Qt import (
|
||||
QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage,
|
||||
pyqtSignal, QStackedLayout, QWidget, QLabel, Qt, QComboBox, QPixmap,
|
||||
QGridLayout, QStyledItemDelegate, QModelIndex, QApplication, QStaticText,
|
||||
QStyle, QPen
|
||||
QStyle, QPen, QColor, QPainter
|
||||
)
|
||||
|
||||
from calibre import walk, fit_image, human_readable
|
||||
@ -31,7 +31,7 @@ from calibre.utils.date import utcnow
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.utils.https import get_https_resource_securely, HTTPError
|
||||
from calibre.utils.icu import numeric_sort_key as sort_key
|
||||
from calibre.utils.magick import create_canvas, Image
|
||||
from calibre.utils.img import image_from_data, image_to_data
|
||||
from calibre.utils.zipfile import ZipFile, ZIP_STORED
|
||||
from calibre.utils.filenames import atomic_rename
|
||||
from lzma.xz import compress, decompress
|
||||
@ -153,7 +153,9 @@ def default_cover_icons(cols=5):
|
||||
def create_cover(report, icons=(), cols=5, size=60, padding=8):
|
||||
icons = icons or tuple(default_cover_icons(cols))
|
||||
rows = int(math.ceil(len(icons) / cols))
|
||||
canvas = create_canvas(cols * (size + padding), rows * (size + padding), '#eeeeee')
|
||||
canvas = QImage(cols * (size + padding), rows * (size + padding), QImage.Format_RGB32)
|
||||
canvas.fill(QColor('#eeeeee'))
|
||||
p = QPainter(canvas)
|
||||
y = -size - padding // 2
|
||||
x = 0
|
||||
for i, icon in enumerate(icons):
|
||||
@ -166,15 +168,14 @@ def create_cover(report, icons=(), cols=5, size=60, padding=8):
|
||||
ipath = os.path.join(report.path, report.name_map[icon])
|
||||
else:
|
||||
ipath = I(icon, allow_user_override=False)
|
||||
img = Image()
|
||||
with open(ipath, 'rb') as f:
|
||||
img.load(f.read())
|
||||
scaled, nwidth, nheight = fit_image(img.size[0], img.size[1], size, size)
|
||||
img.size = nwidth, nheight
|
||||
with lopen(ipath, 'rb') as f:
|
||||
img = image_from_data(f.read())
|
||||
scaled, nwidth, nheight = fit_image(img.width(), img.height(), size, size)
|
||||
img = img.scaled(nwidth, nheight, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
|
||||
dx = (size - nwidth) // 2
|
||||
canvas.compose(img, x + dx, y)
|
||||
|
||||
return canvas.export('JPEG')
|
||||
p.drawImage(x + dx, y, img)
|
||||
p.end()
|
||||
return image_to_data(canvas)
|
||||
|
||||
def verify_theme(report):
|
||||
must_use_qt()
|
||||
|
Loading…
x
Reference in New Issue
Block a user