Skip to content

Commit

Permalink
Add scikit-image for resizing
Browse files Browse the repository at this point in the history
* Add scikit-image and scipy as requirement for resizing images
* Resize all images to 700x315
  • Loading branch information
firstof9 committed Feb 18, 2020
1 parent 2b58eac commit 84fc5da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/mail_and_packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"dependencies": [],
"codeowners": ["@moralmunky","@firstof9"],
"config_flow": true,
"requirements": [ "imageio" ]
"requirements": [ "imageio", "scipy", "scikit-image" ]
}
6 changes: 5 additions & 1 deletion custom_components/mail_and_packages/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import asyncio
import imageio as io
from skimage.transform import resize
import os
import re
import imaplib
Expand Down Expand Up @@ -142,7 +143,6 @@ def update(self):
# Subtract the number of delivered packages from those in transit
if self._packages_transit >= self._packages_delivered:
self._packages_transit -= self._packages_delivered


else:
_LOGGER.debug("Host was left blank not attempting connection")
Expand Down Expand Up @@ -830,6 +830,10 @@ def get_mails(account, image_output_path):
if image_count > 0:
all_images = []

_LOGGER.debug("Resizing images to 700x315...")
# Resize images to 700x315
images = [resize(image, (700, 315)) for image in images]

_LOGGER.debug("Creating array of image files...")
# Create numpy array of images
all_images = [io.imread(image) for image in images]
Expand Down

0 comments on commit 84fc5da

Please sign in to comment.