1What's new in Wand 0.6? 2======================= 3 4This guide doesn't cover all changes in 0.6. See the full list of changes 5in :ref:`changelog-0.6`. 6 7CMYK & Gray Color Spaces Added to Numpy's Array Interface 8''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 9 10.. versionadded:: 0.6.2 11 12When exporting pixel data into a Numpy array, Gray & CMYK color-spaces will 13be represented. 14 15Note that the shape of the array only has one data channel for grayscale images. 16 17>>> with Image(filename="rose:") as img: 18... img.transform_colorspace("gray") 19... print(np.array(img).shape) 20(46, 70, 1) 21 22As expected, CMYK images will export 4 bytes for each color channel. 23 24>>> with Image(filename="rose:") as img: 25... img.transform_colorspace("cmyk") 26... print(np.array(img).shape) 27(46, 70, 4) 28 29Numpy array's do not transport channel assignment by default, so users will be 30responsible for passing this information back into a raster library. 31 32>>> with Image.form_array(my_cmyk_array, channel_map="cmyk") as img: 33... img.save(filename="output.tiff") 34 35Users expecting to keep RGBA array shapes should perform color space 36transformations before passing to Numpy. 37 38>>> with Image(filename="cmyk_photo.tiff") as img: 39... if img.colorspace == "cmyk": 40... img.transform_colorspace("srgb") 41... arr = numpy.array(img) 42... arr = cv2.cvtColor(arr, cv2.COLOR_RGB2BGR) 43 44 45Completed MagickWand API 46'''''''''''''''''''''''' 47 48The majority of the MagickWand API has been integrated into Wand between 490.5 & 0.6 release. Documentation referring to incomplete, or minimal 50integrations of the API have been updated. 51 52Ensure to run Wand with the latest ImageMagick-7 library to take advantage 53of all the new methods. 54 55 - :meth:`Image.auto_threshold() <wand.image.BaseImage.auto_threshold>` method. 56 - :meth:`Image.canny() <wand.image.BaseImage.canny>` method. 57 - :meth:`Image.clahe() <wand.image.BaseImage.canny>` method. Also known as "Contrast Limited Adaptive Histogram Equalization". 58 - :meth:`Image.color_threshold() <wand.image.BaseImage.color_threshold>` method. 59 - :meth:`Image.complex() <wand.image.BaseImage.complex>` method. 60 - :meth:`Image.connected_components() <wand.image.BaseImage.connected_components>` method. 61 - :meth:`Image.convex_hull() <wand.image.BaseImage.convex_hull>` method. 62 - :meth:`Image.hough_lines() <wand.image.BaseImage.hough_lines>` method. 63 - :meth:`Image.kmeans() <wand.image.BaseImage.kmeans>` method. 64 - :meth:`Image.kuwahara() <wand.image.BaseImage.kuwahara>` method. 65 - :meth:`Image.level_colors() <wand.image.BaseImage.level_colors>` method. 66 - :meth:`Image.levelize() <wand.image.BaseImage.levelize>` method. 67 - :meth:`Image.levelize_colors() <wand.image.BaseImage.levelize_colors>` method. 68 - :meth:`Image.local_contrast() <wand.image.BaseImage.local_contrast>` method. 69 - :meth:`Image.mean_shift() <wand.image.BaseImage.mean_shift>` method. 70 - :meth:`Image.minimum_bounding_box() <wand.image.BaseImage.minimum_bounding_box>` method. 71 - :meth:`Image.polynomial() <wand.image.BaseImage.polynomial>` method. 72 - :meth:`Image.range_threshold() <wand.image.BaseImage.range_threshold>` method. 73 - :meth:`Image.read_mask() <wand.image.BaseImage.read_mask>` method. 74 - :meth:`Image.rotational_blur() <wand.image.BaseImage.rotational_blur>` method. 75 - :meth:`Image.wavelet_denoise() <wand.image.BaseImage.wavelet_denoise>` method. 76 - :meth:`Image.white_balance() <wand.image.BaseImage.white_balance>` method. 77 - :meth:`Image.write_mask() <wand.image.BaseImage.write_mask>` method. 78 79 80Numpy I/O Fixes 81''''''''''''''' 82 83The original integration of Numpy's array interface exported shape data as 84``( WIDTH, HEIGHT, CHANNELS )``. However many other imaging libraries that work 85with Numpy expect this shape data as ``( ROWS, COLUMNS, CHANNELS )``. Wand-0.6 86adjusted the shape data to be in alignment & compatible with other libraries. 87 88 89Documentation & Test Cases Ship with Source Distribution 90'''''''''''''''''''''''''''''''''''''''''''''''''''''''' 91 92The source distribution now includes Wand's `reStructuredText`_ documentation, 93and `pytest`_ regression tests source files. Hopefully this will help offline 94users. See :ref:`running-tests` document for info on local testing. 95 96Use setuptools-extra to install additional development dependencies:: 97 98 pip install -U Wand[doc,test] 99 100.. _reStructuredText: https://en.wikipedia.org/wiki/ReStructuredText 101.. _pytest: https://docs.pytest.org/en/latest/ 102 103 104Improved Memory Deallocation & :mod:`atexit` Support 105'''''''''''''''''''''''''''''''''''''''''''''''''''' 106 107Several memory leaks have been addressed by reworking the :mod:`wand.resource` 108allocation & deallocation functions. 109 110It's still recommended to use Wand's :class:`Image <wand.image.Image>` class 111in a ``with`` statement for proper memory-resource context:: 112 113 with Image(filename='input.jpg') as img: 114 pass 115 116Users not using the ``with`` statement forfeit memory deallocation over to 117Python's garbage-collector :mod:`gc` module. 118 119The :c:func:`MagickWandTerminus()` function is now only called during Python's 120:mod:`atexit` shutdown routine. 121 122.. note:: 123 124 For "What's New in Wand 0.5", see `previous announcements`_. 125 126 .. _previous announcements: 0.5.html 127