fix tests for image module

This commit is contained in:
aceisace 2022-04-14 05:53:10 +02:00
parent 661aab45d4
commit c718d4831f
2 changed files with 13 additions and 3 deletions

View File

@ -15,6 +15,8 @@ import numpy
import os import os
import logging import logging
from PIL.Image import Resampling
filename = os.path.basename(__file__).split('.py')[0] filename = os.path.basename(__file__).split('.py')[0]
logger = logging.getLogger(filename) logger = logging.getLogger(filename)
@ -178,7 +180,7 @@ class Inkyimage:
initial_width = image.width initial_width = image.width
wpercent = (width / float(image.width)) wpercent = (width / float(image.width))
hsize = int((float(image.height) * float(wpercent))) hsize = int((float(image.height) * float(wpercent)))
image = image.resize((width, hsize), Image.ANTIALIAS) image = image.resize((width, hsize), Resampling.LANCZOS)
logger.info(f"resized image from {initial_width} to {image.width}") logger.info(f"resized image from {initial_width} to {image.width}")
self.image = image self.image = image
@ -186,7 +188,7 @@ class Inkyimage:
initial_height = image.height initial_height = image.height
hpercent = (height / float(image.height)) hpercent = (height / float(image.height))
wsize = int(float(image.width) * float(hpercent)) wsize = int(float(image.width) * float(hpercent))
image = image.resize((wsize, height), Image.ANTIALIAS) image = image.resize((wsize, height), Resampling.LANCZOS)
logger.info(f"resized image from {initial_height} to {image.height}") logger.info(f"resized image from {initial_height} to {image.height}")
self.image = image self.image = image

View File

@ -6,6 +6,10 @@ Copyright by aceisace
""" """
import unittest import unittest
import requests
from PIL import Image
from inkycal.modules import Inkyimage as Module from inkycal.modules import Inkyimage as Module
from inkycal.custom import top_level from inkycal.custom import top_level
from helper_functions import * from helper_functions import *
@ -15,7 +19,11 @@ environment = get_environment()
# Set to True to preview images. Only works on Raspberry Pi OS with Desktop # Set to True to preview images. Only works on Raspberry Pi OS with Desktop
use_preview = False use_preview = False
test_path = f'{top_level}/Gallery/coffee.png' url = "https://github.com/aceisace/Inkycal/raw/assets/Repo/coffee.png"
im = Image.open(requests.get(url, stream=True).raw)
im.save("test.png", "PNG")
test_path = "test.png"
tests = [ tests = [
{ {