Skip to content

Commit

Permalink
Merge branch '0.3-maintenance'
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Dec 19, 2014
2 parents 10e414d + 46a33c3 commit f027b9e
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 12 deletions.
10 changes: 8 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ Wand Changelog
Version 0.3.9
-------------

To be released.
Released on December 20, 2014.

- Added ``'pdf:use-cropbox'`` option to :attr:`Image.options
<wand.image.BaseImage.options>` dictionary (and :const:`~wand.image.OPTIONS`
constant). [:issue:`185` by Christoph Neuroth]
- Fixed a bug that exception message was :class:`bytes` instead of
:class:`str` on Python 3.
- The ``size`` parameter of :class:`~wand.font.Font` class becomes optional.
Its default value is 0, which means *autosized*.
[:issue:`191` by Cha, Hojeong]
- Fixed a bug that :meth:`Image.read() <wand.image.Image.read>` had tried
using :c:func:`MagickReadImageFile()` even when the given file object
has no :attr:`mode` attribute. [:issue:`205` by Stephen J. Fuhry]


Version 0.3.8
Expand Down Expand Up @@ -258,7 +264,7 @@ Released on January 25, 2013.
<wand.image.Image.transparentize>` method (and :meth:`Image.watermark()
<wand.image.Image.watermark>` method which internally uses it) didn't
work.
- Fixed segmentation fault occured when :attr:`Color.red
- Fixed segmentation fault occurred when :attr:`Color.red
<wand.color.Color.red>`, :attr:`Color.green <wand.color.Color.green>`,
or :attr:`Color.blue <Wand.color.Color.blue>` is accessed.
- Added :attr:`Color.alpha <wand.color.Color.alpha>` property.
Expand Down
7 changes: 7 additions & 0 deletions docs/guide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ easily installed using APT:

$ sudo apt-get install libmagickwand-dev

If you need SVG, WMF, OpenEXR, DjVu, and Graphviz support you have to install
``libmagickcore5-extra`` as well:

.. sourcecode:: console

$ sudo apt-get install libmagickcore5-extra


.. _install-imagemagick-redhat:

Expand Down
2 changes: 1 addition & 1 deletion docs/roadmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Very future versions

PIL compatibility layer
PIL has very long history and the most of Python projects still
depend on it. We will work on PIL compatiblity layer using Wand.
depend on it. We will work on PIL compatibility layer using Wand.
It will provide two ways to emulate PIL:

- Module-level compatibility which can be used by changing
Expand Down
25 changes: 25 additions & 0 deletions tests/image_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
import codecs
import io
import os
import os.path
import shutil
import sys
import tempfile
import warnings

Expand All @@ -15,6 +17,23 @@
from wand.font import Font


try:
filesystem_encoding = sys.getfilesystemencoding()
except RuntimeError:
unicode_filesystem_encoding = False
else:
try:
codec_info = codecs.lookup(filesystem_encoding)
except LookupError:
unicode_filesystem_encoding = False
else:
unicode_filesystem_encoding = codec_info.name in (
'utf-8', 'utf-16', 'utf-16-be', 'utf-16-le',
'utf-32', 'utf-32-be', 'utf-32-le',
'mbcs' # for Windows
)


def test_empty_image():
with Image() as img:
assert img.size == (0,0)
Expand Down Expand Up @@ -58,6 +77,8 @@ def test_read_from_filename(fx_asset):
assert img.width == 402


@mark.skipif(not unicode_filesystem_encoding,
reason='Unicode filesystem encoding needed')
def test_read_from_unicode_filename(fx_asset, tmpdir):
"""https://github.com/dahlia/wand/issues/122"""
filename = '모나리자.jpg'
Expand Down Expand Up @@ -97,6 +118,8 @@ def test_new_from_filename(fx_asset):
Image(filename=str(fx_asset.join('not-exists.jpg')))


@mark.skipif(not unicode_filesystem_encoding,
reason='Unicode filesystem encoding needed')
def test_new_from_unicode_filename(fx_asset, tmpdir):
"""https://github.com/dahlia/wand/issues/122"""
filename = '모나리자.jpg'
Expand Down Expand Up @@ -155,6 +178,8 @@ def test_save_to_filename(fx_asset):
os.remove(savefile)


@mark.skipif(not unicode_filesystem_encoding,
reason='Unicode filesystem encoding needed')
def test_save_to_unicode_filename(fx_asset, tmpdir):
filename = '모나리자.jpg'
if not PY3:
Expand Down
2 changes: 1 addition & 1 deletion wand/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __del__(self):

def find_library(suffix=''):
"""Finds library path to try loading. The result paths are not
guarenteed that they exist.
guaranteed that they exist.
:param suffix: optional suffix e.g. ``'-Q16'``
:type suffix: :class:`basestring`
Expand Down
19 changes: 15 additions & 4 deletions wand/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@


class Font(tuple):
"""Font struct which is a subtype of :class:`tuple`. Its constructor
takes :attr:`path`, :attr:`size`, :attr:`color` (black by default), and
:attr:`antialias` (``True`` by default).
"""Font struct which is a subtype of :class:`tuple`.
:param path: the path of the font file
:type path: :class:`str`, :class:`basestring`
:param size: the size of typeface. 0 by default which means *autosized*
:type size: :class:`numbers.Real`
:param color: the color of typeface. black by default
:type color: :class:`~wand.color.Color`
:param antialias: whether to use antialiasing. :const:`True` by default
:type antialias: :class:`bool`
.. versionchanged:: 0.3.9
The ``size`` parameter becomes optional. Its default value is
0, which means *autosized*.
"""

def __new__(cls, path, size, color=None, antialias=True):
def __new__(cls, path, size=0, color=None, antialias=True):
if not isinstance(path, string_type):
raise TypeError('path must be a string, not ' + repr(path))
if not isinstance(size, numbers.Real):
Expand Down
8 changes: 4 additions & 4 deletions wand/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ class Image(BaseImage):
default is transparent
:type background: :class:`wand.color.Color`
:param resolution: set a resolution value (dpi),
usefull for vectorial formats (like pdf)
useful for vectorial formats (like pdf)
:type resolution: :class:`collections.Sequence`,
:Class:`numbers.Integral`
Expand Down Expand Up @@ -1940,7 +1940,7 @@ def __init__(self, image=None, blob=None, file=None, filename=None,
open_args = image, blob, file, filename
if (any(a is not None for a in new_args) and
any(a is not None for a in open_args)):
raise TypeError('blank image parameters cant be used with image '
raise TypeError("blank image parameters can't be used with image "
'opening parameters')
elif any(a is not None and b is not None
for i, a in enumerate(open_args)
Expand Down Expand Up @@ -2004,7 +2004,7 @@ def read(self, file=None, filename=None, blob=None, resolution=None):
:param filename: reads an image from the ``filename`` string
:type filename: :class:`basestring`
:param resolution: set a resolution value (DPI),
usefull for vectorial formats (like PDF)
useful for vectorial formats (like PDF)
:type resolution: :class:`collections.Sequence`,
:class:`numbers.Integral`
Expand All @@ -2024,7 +2024,7 @@ def read(self, file=None, filename=None, blob=None, resolution=None):
'integer of the same x/y')
if file is not None:
if (isinstance(file, file_types) and
hasattr(libc, 'fdopen')):
hasattr(libc, 'fdopen') and hasattr(file, 'mode')):
fd = libc.fdopen(file.fileno(), file.mode)
r = library.MagickReadImageFile(self.wand, fd)
elif not callable(getattr(file, 'read', None)):
Expand Down

0 comments on commit f027b9e

Please sign in to comment.