<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last modified: <NAME> (<EMAIL>)

"""
generate gif thumb
"""

__revision__ = '0.1'



import PIL
from PIL import Image

def create_thumb(origin_path, thumb_path):
    pilIm = PIL.Image.open(origin_path)
    pilIm.seek(0)
    
    '''
    total_frames = 0
    while True:
        total_frames = pilIm.tell()
        try:
            pilIm.seek(pilIm.tell() + 1)
        except EOFError:
            break
        
    pilIm.seek(0)
    palette = pilIm.getpalette()
    while True:
        if pilIm.tell() >= total_frames/2:
            break
        try:
            pilIm.seek(pilIm.tell() + 1)
        except EOFError:
            break

    pilIm.putpalette(palette)
    '''
    frame = pilIm.convert('RGBA')
    white_bg = Image.new('RGB', frame.size, (255, 255, 255))
    white_bg.paste(frame, mask = frame.split()[-1])
    white_bg.thumbnail((100, 100), PIL.Image.ANTIALIAS)
    white_bg.save(thumb_path, 'JPEG', quality=80)<commit_msg>updated 按照pep8规范修改代码<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last modified: <NAME> (<EMAIL>)

"""
generate gif thumb
"""

__revision__ = '0.1'

import PIL
from PIL import Image


def create_thumb(origin_path, thumb_path):
    pilIm = PIL.Image.open(origin_path)
    pilIm.seek(0)

    frame = pilIm.convert('RGBA')
    white_bg = Image.new('RGB', frame.size, (255, 255, 255))
    white_bg.paste(frame, mask=frame.split()[-1])
    white_bg.thumbnail((100, 100), PIL.Image.ANTIALIAS)
    white_bg.save(thumb_path, 'JPEG', quality=80)
{'fraction_non_alphanumeric': 0.1517684887459807, 'fraction_numerical': 0.03215434083601286, 'mean_word_length': 2.7314148681055155, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '2037921', 'n_tokens_mistral': 624, 'n_tokens_neox': 589, 'n_words': 111}