Skip to content

Commit

Permalink
Replace Pillow with pypng
Browse files Browse the repository at this point in the history
  • Loading branch information
godwhoa committed Mar 28, 2019
1 parent 6485081 commit 6af2ac6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ COPY requirements.txt /usr/src/app/
# Note: manylinux wheel support isn't enabled by default for alpinelinux
# we temporarly enable it for pyenet since it is compatible
RUN apk add --no-cache --virtual .build-deps-cython gcc musl-dev \
&& apk add --no-cache --virtual .build-deps-pillow zlib-dev jpeg-dev libffi-dev openssl-dev \
&& apk add --no-cache zlib jpeg \
&& apk add --no-cache --virtual .build-deps-crypto libffi-dev openssl-dev \
\
&& echo "manylinux1_compatible = True" > /usr/local/lib/python3.6/_manylinux.py \
&& pip install pyenet \
&& rm /usr/local/lib/python3.6/_manylinux.py \
&& pip install --no-cache-dir -r requirements.txt \
\
&& apk del .build-deps-cython \
&& apk del .build-deps-pillow
&& apk del .build-deps-crypto

# The fact that we removed gcc beforehand makes us download it again
# This is remedied by building the server core first and leaving all .py scripts
Expand Down
6 changes: 3 additions & 3 deletions piqueserver/statusserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import json
from io import BytesIO

from PIL import Image
import png
from jinja2 import Environment, PackageLoader
from twisted.internet import reactor
from twisted.web import server
Expand Down Expand Up @@ -135,9 +135,9 @@ def get_overview(self):
self.last_map_name != self.protocol.map_info.name or
current_time - self.last_overview > OVERVIEW_UPDATE_INTERVAL):
overview = self.protocol.map.get_overview(rgba=True)
image = Image.frombytes('RGBA', (512, 512), overview)
w = png.Writer(512, 512, alpha=True)
data = BytesIO()
image.save(data, 'png')
w.write_array(data, overview)
self.overview = data.getvalue()
self.last_overview = current_time
self.last_map_name = self.protocol.map_info.name
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Cython>=0.27,<1
Twisted[tls]>=17
Jinja2>=2,<3
Pillow>=5.1.0,<6
pyenet
typing
toml
pypng==0.0.19

# from command
pygeoip>=0.3.2,<0.4
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ def run(self):
'Cython>=0.27,<1',
'Twisted[tls]>=17,<19',
'Jinja2>=2,<3', # status server is part of our 'vanilla' package
'Pillow>=5.1.0,<6',
'pypng==0.0.19',
'pyenet',
'toml',
'typing'
],
extras_require={
'from': ['geoip2>=2.9,<3.0'],
# 'statusserver': ['Jinja2>=2.8,<2.9', 'Pillow>=3.4.2,<3.5'],
# 'statusserver': ['Jinja2>=2.8,<2.9', 'pypng==0.0.19'],
'ssh': [
'cryptography>=2.1.4,<2.2',
'pyasn1>=0.4.2,<0.5'
Expand Down

0 comments on commit 6af2ac6

Please sign in to comment.