<commit_before># -*- coding: utf-8 -*-
import os
import shutil

from PIL import Image


def image_size_off(rootDir):
    '''
    jpg:裁剪为75*75的缩略图
    gif：直接用现成的缩略图
    '''

    for lists in os.listdir(rootDir):
        # 需要什么格式的图片自己手动改改就好了
        suffix = lists[lists.rfind('.'):].lower()
        path = os.path.join(rootDir, lists)
        if suffix == '.jpg':
            try:
                im = Image.open(path).convert('RGB')
                box = clipimage(im.size)
                region = im.crop(box)
                size = (75, 75)
                region.thumbnail(size, Image.ANTIALIAS)
                # 这里保存thumbnail以后的结果
                region.save(
                    os.path.join('/home/guzi/github/Python/tmp-s', lists))
            except Exception, e:
                print lists, e.message
        elif suffix == '.gif':
                try:
                    shutil.copy('/home/guzi/github/Python/repeat/default.jpg', os.path.join('/home/guzi/github/Python/tmp-s', lists))
                except Exception, e:
                    print lists, e.message


# 取宽和高的值小的那一个来生成裁剪图片用的box
# 并且尽可能的裁剪出图片的中间部分,一般人摄影都会把主题放在靠中间的,个别艺术家有特殊的艺术需求我顾不上
def clipimage(size):
    width = int(size[0])
    height = int(size[1])
    box = ()
    if (width > height):
        dx = width - height<commit_msg>produce thumbnails from png,jpg and gif<commit_after># -*- coding: utf-8 -*-
import os
import shutil

from PIL import Image


def image_size_off(rootDir):
    '''
    jpg:裁剪为75*75的缩略图
    gif：直接用现成的缩略图
    '''

    for lists in os.listdir(rootDir):
        # 需要什么格式的图片自己手动改改就好了
        suffix = lists[lists.rfind('.'):].lower()
        path = os.path.join(rootDir, lists)
        if suffix == '.jpg' or suffix == '.png':
            try:
                im = Image.open(path).convert('RGB')
                box = clipimage(im.size)
                region = im.crop(box)
                size = (75, 75)
                region.thumbnail(size, Image.ANTIALIAS)
                # 这里保存thumbnail以后的结果
                region.save(
                    os.path.join('/home/guzi/github/Python/tmp-s', lists))
            except Exception, e:
                print lists, e.message
        elif suffix == '.gif':
                try:
                    shutil.copy('/home/guzi/github/Python/repeat/default.jpg', os.path.join('/home/guzi/github/Python/tmp-s', lists))
                except Exception, e:
                    print lists, e.message


# 取宽和高的值小的那一个来生成裁剪图片用的box
# 并且尽可能的裁剪出图片的中间部分,一般人摄影都会把主题放在靠中间的,个别艺术家有特殊的艺术需求我顾不上
def clipimage(size):
    width = int(size[0])
    height = int(size[1])
    box = ()
    if (width > height):
        dx = width - height
{'fraction_non_alphanumeric': 0.12603150787696923, 'fraction_numerical': 0.008252063015753939, 'mean_word_length': 1.7410071942446044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5172404', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1013, 'n_words': 163}