diff --git a/text/Dockerfile b/text/Dockerfile index 7c7fa15..83d3b87 100644 --- a/text/Dockerfile +++ b/text/Dockerfile @@ -4,9 +4,8 @@ WORKDIR /usr/src/app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -RUN python -m nltk.downloader -d /usr/local/share/nltk_data wordnet WORKDIR /opt/work #COPY . . -#CMD [ "python", "./your-daemon-or-script.py" ] \ No newline at end of file +#CMD [ "python", "./your-daemon-or-script.py" ] diff --git a/text/build.sh b/text/build.sh index 96810e8..0de19e3 100755 --- a/text/build.sh +++ b/text/build.sh @@ -1,2 +1,2 @@ #!/bin/bash -docker build . -t python-data-art \ No newline at end of file +docker build . -t python-data-art diff --git a/text/pil.py b/text/pil.py index bcb0565..3807b0d 100644 --- a/text/pil.py +++ b/text/pil.py @@ -8,8 +8,7 @@ - https://stackoverflow.com/questions/704152/how-can-i-convert-a-character-to-a-integer-in-python-and-viceversa """ import math -from PIL import Image, ImageColor -import nltk +from PIL import Image """ @@ -46,10 +45,14 @@ def get_img_dim(text): -height = int(math.sqrt(len(text))) / 3 -width = height +num_pixels = math.ceil(len(text) / 3) +height = width = int(math.ceil(math.sqrt(num_pixels))) print("[*] w = {0}, h = {1}".format(width, height)) +expected_len = width * height * 3 +if len(text) < expected_len: + text = text.ljust(expected_len, '\0') + #get_img_dim(text) im = Image.new('RGBA', (width, height)) @@ -66,4 +69,4 @@ def get_img_dim(text): im.putpixel((x, y), (ord(text[i]), ord(text[i+1]), ord(text[i+2]))) i = i + 3 -im.save('putPixel.png') \ No newline at end of file +im.save('putPixel.png') diff --git a/text/requirements.txt b/text/requirements.txt index 8008058..5aa65d7 100644 --- a/text/requirements.txt +++ b/text/requirements.txt @@ -1,4 +1,2 @@ ###### Requirements without Version Specifiers ###### -#nose -#nose-cov -nltk \ No newline at end of file +Pillow diff --git a/text/run.sh b/text/run.sh index 4be0bc2..892f76f 100755 --- a/text/run.sh +++ b/text/run.sh @@ -1,2 +1,2 @@ #!/bin/bash -docker container run -it --rm -v $(pwd):/opt/work python-data-art bash \ No newline at end of file +docker container run -it --rm -v $(pwd):/opt/work python-data-art bash