Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Unreleased.
- Fixed :meth:`Image.liquid_rescale() <wand.image.BaseImage.liquid_rescale>` behavior
by switching default value of ``delta_x`` from ``0`` to ``1``. [:issue:`653`]
- Fixed :meth:`Image.sparse_color() <wand.image.BaseImage.sparse_color>`'s ``colors`` argument structure to allow multiple (x, y) points with the same color value.
- Fixed offset coordinates when used with ``gravity`` parameters. [:issue:`669`]

- :meth:`Image.chop() <wand.image.BaseImage.chop>`
- :meth:`Image.composite() <wand.image.BaseImage.composite>`
- :meth:`Image.composite_channel() <wand.image.BaseImage.composite_channel>`
- :meth:`Image.crop() <wand.image.BaseImage.crop>`
- :meth:`Image.extent() <wand.image.BaseImage.extent>`
- :meth:`Image.region() <wand.image.BaseImage.region>`
- :meth:`Image.splice() <wand.image.BaseImage.splice>`

- [TEST] Added Python 3.12 regression test. [:issue:`648` by Thijs Triemstra]


Expand Down
40 changes: 19 additions & 21 deletions tests/image_methods_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ def test_chop_gravity():
with Image(filename='rose:') as img:
img.chop(width=10, height=10, gravity='south_east')
assert (60, 36, 0, 0) == img.page
with raises(ValueError):
with Image(filename='rose:') as img:
img.chop(x=10, gravity='north')
with Image(filename='rose:') as img:
img.chop(width=10, height=10, x=10, y=10, gravity='north')
assert (60, 36, 0, 0) == img.page


@mark.skipif(MAGICK_VERSION_NUMBER < 0x709,
Expand Down Expand Up @@ -660,14 +660,6 @@ def test_crop_gravity(fx_asset):
assert southeast[mid_width, mid_height] == Color('transparent')


def test_crop_gravity_error():
with Image(filename='rose:') as img:
with raises(TypeError):
img.crop(gravity='center')
with raises(ValueError):
img.crop(width=1, height=1, gravity='nowhere')


def test_crop_issue367():
with Image(filename='rose:') as img:
expected = img.size
Expand All @@ -679,6 +671,12 @@ def test_crop_issue367():
assert actual.size == expected


def test_crop_issue669():
with Image(filename='rose:') as img:
img.crop(width=50, height=25, left=10, gravity='south')
assert 50, 25 == img.size


def test_cycle_color_map(fx_asset):
with Image(filename=str(fx_asset.joinpath('trim-color-test.png'))) as img:
img.type = 'palette'
Expand Down Expand Up @@ -874,9 +872,9 @@ def test_extent_gravity():
assert (10, 10, 0, 0) == img.page
img.extent(width=100, height=100, gravity='center')
assert (100, 100, 0, 0) == img.page
with raises(ValueError):
with Image(filename='rose:') as img:
img.extent(x=10, gravity='north')
with Image(filename='rose:') as img:
img.extent(x=10, gravity='north')
assert 70, 46 == img.size


def test_features():
Expand Down Expand Up @@ -1730,10 +1728,10 @@ def test_region():
with src.region(width=10, height=10, gravity='south_east') as dst:
assert (70, 46, 60, 36) == dst.page
assert (10, 10) == dst.size
with raises(ValueError):
with Image(filename='rose:') as img:
with img.region(x=10, gravity='center') as _:
pass
with Image(filename='rose:') as img:
with img.region(x=10, gravity='center') as dst:
assert (70, 46, 10, 0) == dst.page
assert (60, 46) == dst.size


def test_remap():
Expand Down Expand Up @@ -2155,9 +2153,9 @@ def test_splice():
was = img.signature
img.splice(width=10, height=10, gravity='center')
assert img.signature != was
with raises(ValueError):
with Image(filename='rose:') as img:
img.splice(width=10, height=10, x=10, gravity='center')
with Image(filename='rose:') as img:
img.splice(width=10, height=10, x=10, gravity='center')
assert (80, 56) == img.size


def test_spread():
Expand Down
Loading