From: Orakaro Date: Fri, 6 Jun 2014 16:50:28 +0000 (+0900) Subject: enable image view by argv X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=816e305ff47ca527c3629861b73068136bbfd6f0;p=rainbowstream.git enable image view by argv --- diff --git a/rainbowstream/c_image.py b/rainbowstream/c_image.py index 95e1c66..59e64b0 100644 --- a/rainbowstream/c_image.py +++ b/rainbowstream/c_image.py @@ -1,6 +1,7 @@ from PIL import Image from functools import partial from os.path import join, dirname, getmtime, exists, expanduser +from .config import * import ctypes import sys @@ -30,14 +31,14 @@ def image_to_display(path): w, h = i.size i.load() rows, columns = os.popen('stty size', 'r').read().split() - width = min(w, int(columns) - 2 * 6) + width = min(w, int(columns) - 2 * IMAGE_SHIFT) height = int(float(h) * (float(width) / float(w))) height //= 2 i = i.resize((width, height), Image.BICUBIC) - height = min(height, 30) + height = min(height, IMAGE_MAX_HEIGHT) for y in xrange(height): - print ' ' * 6, + print ' ' * IMAGE_SHIFT, for x in xrange(width): p = i.getpixel((x, y)) r, g, b = p[:3] diff --git a/rainbowstream/config.py b/rainbowstream/config.py index a77c2cb..24306de 100644 --- a/rainbowstream/config.py +++ b/rainbowstream/config.py @@ -13,3 +13,7 @@ DOMAIN = USER_DOMAIN # Filter and Ignore list ex: ['@fat','@mdo'] ONLY_LIST = [] IGNORE_LIST = [] + +# Image size +IMAGE_SHIFT = 10 +IMAGE_MAX_HEIGHT = 30 \ No newline at end of file diff --git a/rainbowstream/pure_image.py b/rainbowstream/pure_image.py index f4cb751..11beaa5 100644 --- a/rainbowstream/pure_image.py +++ b/rainbowstream/pure_image.py @@ -1,5 +1,6 @@ from PIL import Image from functools import partial +from .config import * import sys import os @@ -315,14 +316,14 @@ def image_to_display(path): w, h = i.size i.load() rows, columns = os.popen('stty size', 'r').read().split() - width = min(w, int(columns) - 2 * 6) + width = min(w, int(columns) - 2 * IMAGE_SHIFT) height = int(float(h) * (float(width) / float(w))) height //= 2 i = i.resize((width, height), Image.BICUBIC) - height = min(height, 30) + height = min(height, IMAGE_MAX_HEIGHT) for y in xrange(height): - print ' ' * 6, + print ' ' * IMAGE_SHIFT, for x in xrange(width): p = i.getpixel((x, y)) r, g, b = p[:3]