diff --git a/src/calibre/gui2/tweak_book/editor/canvas.py b/src/calibre/gui2/tweak_book/editor/canvas.py index 153b7d7af3..f51f9a3b86 100644 --- a/src/calibre/gui2/tweak_book/editor/canvas.py +++ b/src/calibre/gui2/tweak_book/editor/canvas.py @@ -14,7 +14,6 @@ from PyQt4.Qt import ( QPointF, QPen, pyqtSignal, QUndoCommand, QUndoStack, QIcon, QImage, QByteArray) from calibre import fit_image -from calibre.constants import isosx from calibre.gui2 import error_dialog, pixmap_to_data from calibre.gui2.dnd import ( IMAGE_EXTENSIONS, dnd_has_extension, dnd_has_image, dnd_get_image, DownloadDialog) @@ -94,13 +93,6 @@ def get_pixel_map(): def qimage_to_magick(img): ans = Image() - if isosx: - # For some reson, on OSX MagickConstituteImage fails, and I can't be - # bothered figuring out why. Dumping to uncompressed PNG is reasonably - # fast. - raw = pixmap_to_data(img, 'PNG', quality=100) - ans.load(raw) - return ans fmt = get_pixel_map() if not img.hasAlphaChannel(): if img.format() != img.Format_RGB32: @@ -117,7 +109,7 @@ def qimage_to_magick(img): def magick_to_qimage(img): fmt = get_pixel_map() - # ImageMagick can output only output raw data in some formats that can be + # ImageMagick can only output raw data in some formats that can be # read into QImage directly, if the QImage format is not one of those, use # PNG if fmt in {'RGBA', 'BGRA'}: diff --git a/src/calibre/utils/magick/magick.c b/src/calibre/utils/magick/magick.c index 9aa04b4c96..ce1ccbf71f 100644 --- a/src/calibre/utils/magick/magick.c +++ b/src/calibre/utils/magick/magick.c @@ -540,14 +540,14 @@ magick_Image_new(PyTypeObject *type, PyObject *args, PyObject *kwds) // Image.constitute {{{ static PyObject * magick_Image_constitute(magick_Image *self, PyObject *args) { - const char *map; - Py_ssize_t width, height; - PyObject *capsule; - MagickBooleanType res; - void *data; + const char *map = NULL; + unsigned int width = 0, height = 0; + PyObject *capsule = NULL; + MagickBooleanType res = MagickFalse; + void *data = NULL; NULL_CHECK(NULL) - if (!PyArg_ParseTuple(args, "iisO", &width, &height, &map, &capsule)) return NULL; + if (!PyArg_ParseTuple(args, "IIsO", &width, &height, &map, &capsule)) return NULL; if (!PyCapsule_CheckExact(capsule)) { PyErr_SetString(PyExc_TypeError, "data is not a capsule object"); @@ -557,7 +557,7 @@ magick_Image_constitute(magick_Image *self, PyObject *args) { data = PyCapsule_GetPointer(capsule, PyCapsule_GetName(capsule)); if (data == NULL) return NULL; - res = MagickConstituteImage(self->wand, width, height, map, CharPixel, data); + res = MagickConstituteImage(self->wand, (size_t)width, (size_t)height, map, CharPixel, data); if (!res) return magick_set_exception(self->wand);