mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix a regression in calibre 6.0 that broke processing of very high resolution images. Fixes #1983484 [Cover creation fails](https://bugs.launchpad.net/calibre/+bug/1983484)
This commit is contained in:
parent
9b2adfa777
commit
849d971642
@ -37,6 +37,7 @@ from calibre.utils.config import Config, ConfigProxy, JSONConfig, dynamic
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.date import UNDEFINED_DATE
|
||||
from calibre.utils.file_type_icons import EXT_MAP
|
||||
from calibre.utils.img import set_image_allocation_limit
|
||||
from calibre.utils.localization import get_lang
|
||||
from calibre.utils.resources import user_dir
|
||||
from polyglot import queue
|
||||
@ -1102,6 +1103,7 @@ class Application(QApplication):
|
||||
QApplication.setDesktopFileName(override_program_name)
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts, True) # needed for webengine
|
||||
QApplication.__init__(self, args)
|
||||
set_image_allocation_limit()
|
||||
self.palette_manager.initialize()
|
||||
icon_resource_manager.initialize()
|
||||
sh = self.styleHints()
|
||||
@ -1446,6 +1448,7 @@ def ensure_app(headless=True):
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL, True)
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
|
||||
_store_app = QApplication(args)
|
||||
set_image_allocation_limit()
|
||||
if headless and has_headless:
|
||||
_store_app.headless = True
|
||||
import traceback
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QFormLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPainterPath>
|
||||
#include <QImageReader>
|
||||
#include <algorithm>
|
||||
#include <qdrawutil.h>
|
||||
|
||||
@ -423,3 +424,13 @@ QMenu*
|
||||
menu_for_action(const QAction *ac) {
|
||||
return ac->menu<QMenu*>();
|
||||
}
|
||||
|
||||
void
|
||||
set_image_allocation_limit(int megabytes) {
|
||||
QImageReader::setAllocationLimit(megabytes);
|
||||
}
|
||||
|
||||
int
|
||||
get_image_allocation_limit() {
|
||||
return QImageReader::allocationLimit();
|
||||
}
|
||||
|
@ -160,3 +160,5 @@ void set_no_activate_on_click(QWidget *widget);
|
||||
void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor & light, const QColor & dark);
|
||||
void set_menu_on_action(QAction* ac, QMenu* menu);
|
||||
QMenu* menu_for_action(const QAction *ac);
|
||||
void set_image_allocation_limit(int megabytes);
|
||||
int get_image_allocation_limit();
|
||||
|
@ -87,3 +87,5 @@ void set_no_activate_on_click(QWidget *widget);
|
||||
void draw_snake_spinner(QPainter &painter, QRect rect, int angle, const QColor & light, const QColor & dark) /ReleaseGIL/;
|
||||
void set_menu_on_action(QAction* ac, QMenu* menu);
|
||||
QMenu* menu_for_action(const QAction *ac);
|
||||
void set_image_allocation_limit(int megabytes);
|
||||
int get_image_allocation_limit();
|
||||
|
@ -8,6 +8,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from contextlib import suppress
|
||||
from io import BytesIO
|
||||
from qt.core import (
|
||||
QBuffer, QByteArray, QColor, QImage, QImageReader, QImageWriter, QIODevice,
|
||||
@ -106,6 +107,14 @@ def gif_data_to_png_data(data, discard_animation=False):
|
||||
# Loading images {{{
|
||||
|
||||
|
||||
def set_image_allocation_limit(size_in_mb=1024):
|
||||
with suppress(ImportError): # for people running form source
|
||||
from calibre_extensions.progress_indicator import (
|
||||
set_image_allocation_limit as impl
|
||||
)
|
||||
impl(size_in_mb)
|
||||
|
||||
|
||||
def null_image():
|
||||
' Create an invalid image. For internal use. '
|
||||
return QImage()
|
||||
@ -115,6 +124,7 @@ def image_from_data(data):
|
||||
' Create an image object from data, which should be a bytestring. '
|
||||
if isinstance(data, QImage):
|
||||
return data
|
||||
set_image_allocation_limit()
|
||||
i = QImage()
|
||||
if not i.loadFromData(data):
|
||||
q = what(None, data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user