Skip to content

Commit

Permalink
Merge 906c7eb into 4d21d61
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoon committed Jul 13, 2023
2 parents 4d21d61 + 906c7eb commit 58a4da7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pydecorate/decorator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _add_logo(self, logo_path, **kwargs):
nyi = int(round(nxi * aspect))
ny = nyi + 2 * my

logo = logo.resize((nxi, nyi), resample=Image.ANTIALIAS)
logo = logo.resize((nxi, nyi), resample=Image.Resampling.LANCZOS)

# draw base
px = self.style["propagation"][0] + self.style["newline_propagation"][0]
Expand Down
18 changes: 18 additions & 0 deletions pydecorate/tests/test_decorator_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Tests for the aggdraw-based decorator."""

from pathlib import Path
from unittest import mock

import numpy as np
Expand All @@ -27,6 +28,9 @@

from pydecorate import DecoratorAGG

HERE = Path(__file__).parent
REPO = HERE.parent.parent


@pytest.mark.parametrize(
"orientation_func_name", ["write_vertically", "write_horizontally"]
Expand Down Expand Up @@ -66,6 +70,20 @@ def test_colorbar(tmp_path, orientation_func_name, align_func_name, clims):
)


def test_add_logo(tmp_path):
fn = tmp_path / "add_logo_pytroll.png"
img = Image.fromarray(np.zeros((200, 200, 3), dtype=np.uint8))
dc = DecoratorAGG(img)
dc.add_logo(REPO / "logos" / "pytroll_light_big.png")
img.save(fn)

# Check results
output_img = Image.open(fn)
arr = np.array(output_img)
assert not (arr == 0).all()
assert (arr[-1, -1, :] == 0).all(), "logo is in top left corner"


def assert_colorbar_increasing_tick_order(draw_text_wrapper) -> None:
last_float_text = None
for call_args in draw_text_wrapper.call_args_list:
Expand Down
4 changes: 2 additions & 2 deletions pydecorate/tests/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
DEJAVU_FONT = os.path.join(FONTS_ROOT, "DejaVuSerif.ttf")


def test_style_retention():
def test_style_retention(tmp_path):
# import aggdraw
from PIL import Image
from trollimage.colormap import rdbu
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_style_retention():
# line_opacity=100, width=60, unit='K')

# img.show()
img.save("style_retention.png")
img.save(tmp_path / "style_retention.png")

# #dc.align_right()
# #dc.align_bottom()
Expand Down

0 comments on commit 58a4da7

Please sign in to comment.