diff --git a/gazouilleur/lib/tests.py b/gazouilleur/lib/tests.py index 18dc7f0..ca20267 100644 --- a/gazouilleur/lib/tests.py +++ b/gazouilleur/lib/tests.py @@ -67,9 +67,9 @@ # Check image dependencies if Manet screenshots activated if hasattr(config, 'URL_MANET'): try: - import magickpy + import wand except (NameError, ImportError) as e: - logerr("Could not load module%s.\nERROR: This module is required to activate the Manet screenshots set with URL_MANET in `gazouilleur/config.py`: %s\nERROR: Please check your install or run `pip install MagickPy` in gazouilleur's virtualenv.\n" % (str(e).replace('No module named', ''), config.URL_STATS)) + logerr("Could not load module%s.\nERROR: This module is required to activate the Manet screenshots set with URL_MANET in `gazouilleur/config.py`: %s\nERROR: Please check your install or run `pip install Wand` in gazouilleur's virtualenv.\n" % (str(e).replace('No module named', ''), config.URL_STATS)) exit(1) try: diff --git a/gazouilleur/lib/webmonitor.py b/gazouilleur/lib/webmonitor.py index 948dbf1..b252632 100644 --- a/gazouilleur/lib/webmonitor.py +++ b/gazouilleur/lib/webmonitor.py @@ -3,7 +3,7 @@ import os, re, time from hashlib import sha512 -from magickpy import Image +from wand.image import Image from urllib import quote_plus from w3lib.html import replace_entities from twisted.web import client @@ -84,12 +84,14 @@ def save_screenshot(self, version, retries=3): loggerr("%s: %s %s" % (self.name, type(e), e), self.channel, "WebMonitor-shot") else: try: - i = Image.read(str(name)) w = 200.0 - h = round(i.height * w / i.width) - i2 = i.makeResize(long(w), long(h), 5, 1) thumbname = "%s-small.png" % name[:-4] - i2.write(str(thumbname)) + with Image(filename=name) as i: + iW, iH = i.size + h = round(iH * w / iW) + with i.clone() as i2: + i2.resize(int(w), int(h)) + i2.save(filename=thumbname) os.chmod(thumbname, 0o644) del img, i, i2 except Exception as e: diff --git a/requirements.txt b/requirements.txt index 5d12493..809a8f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ zope.interface twisted==15.1.0 stevedore virtualenvwrapper -w3lib +w3lib==1.12.0 # Mongo pymongo==3.0.3 @@ -24,4 +24,4 @@ pypump==0.5.0 # pip install numpy # matplotlib # pystache -# MagickPy +# Wand