From 9a761497081506a237bcec3319f2608ea7fb4004 Mon Sep 17 00:00:00 2001 From: zuber Date: Tue, 22 Sep 2009 12:11:10 +0200 Subject: [PATCH 1/1] =?utf8?q?Skrypt=20imgconv.py=20tworzy=20teraz=20wi?= =?utf8?q?=C4=99ksze=20obrazki=20(640x960px).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- imgconv.py | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/imgconv.py b/imgconv.py index 4a7a5ea6..a99a67e1 100755 --- a/imgconv.py +++ b/imgconv.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys import os +import shutil from os.path import splitext, dirname, basename, realpath from PIL import Image, ImageFilter, ImageEnhance, ImageOps @@ -58,42 +59,36 @@ for file_name in sys.argv[1:]: # Check ratio if ratio(image) > 1: - images = [crop(image, 0.5), crop(image, 0.5, True)] + images = [crop(image, 0.6), crop(image, 0.6, from_right=True)] else: images = [image] for i, image in enumerate(images): - image = image.filter(ImageFilter.SHARPEN) - - image = image.filter(ImageFilter.MinFilter) - # def convert(i): - # if i > 48: - # return 255 - # return i - # image = image.point(convert) - image = ImageOps.autocontrast(image, cutoff=80) - image = image.convert('L') - image = image.filter(ImageFilter.SHARPEN) - image_name = '%s.%d.png' % (basename(base_name), i) # Save files - small_image = resize(image, 480, 720) - small_image.save(tmp_output_dir + '/' + image_name, optimize=True, bits=8) - os.system('pngnq -n 8 -e .png -d "%s" -f "%s"' % ( + small_image = resize(image, 640, 960) + small_image = small_image.convert('L') + small_image = ImageOps.autocontrast(small_image, cutoff=85) + # small_image = small_image.filter(ImageFilter.SHARPEN) + small_image.save(tmp_output_dir + '/' + image_name) + + os.system('pngnq -n 128 -s 1 -e .png -d "%s" -f "%s"' % ( output_dir, tmp_output_dir + '/' + image_name, )) os.remove(tmp_output_dir + '/' + image_name) - big_image = resize(image, 960, 1440) - big_image.save(tmp_output_dir + '/' + image_name, optimize=True, bits=8) - os.system('pngnq -n 8 -e .png -d "%s" -f "%s"' % ( - big_output_dir, - tmp_output_dir + '/' + image_name, - )) - os.remove(tmp_output_dir + '/' + image_name) + # big_image = resize(image, 960, 1440) + # big_image = big_image.convert('L') + # big_image = big_image.filter(ImageFilter.SHARPEN) + # big_image.save(tmp_output_dir + '/' + image_name, optimize=True) + # os.system('pngnq -n 16 -s 1 -e .png -d "%s" -f "%s"' % ( + # big_output_dir, + # tmp_output_dir + '/' + image_name, + # )) + # os.remove(tmp_output_dir + '/' + image_name) sys.stderr.write('.') -os.remove(tmp_output_dir) +shutil.rmtree(tmp_output_dir) -- 2.20.1