<jupyter_start><jupyter_text>html to png<jupyter_code>path = ''
fdir = os.getcwd()
fs = glob.glob(path + "*.html")
    
# driver = webdriver.Chrome()
driver = webdriver.Chrome('chromedriver.exe')

for f in fs:
    # 通常モードでサイズのずれをなくす方法
#     driver = webdriver.Chrome()
    h_add = driver.execute_script("return window.outerHeight - window.innerHeight;")
    w_add = driver.execute_script("return window.outerWidth - window.innerWidth;")

    driver.get(r'file:///' + fdir + '\\' + f)
#     driver.set_window_size(1560 + w_add, 430 + h_add)  # outerWidth, outerHeight を指定する
    driver.set_window_size(1560 + w_add, 780 + h_add)  # outerWidth, outerHeight を指定する
    
    time.sleep(2) # 秒
    
    driver.save_screenshot(f[:-4] + 'png')  # 取得される画像サイズは innerWidth x innerHeight
#     driver.close()

driver.quit()<jupyter_output><empty_output><jupyter_text>png 2 gif<jupyter_code>from PIL import Image
fs = glob.glob(path + "*.png")
imgs = [Image.open(f) for f in fs]

# appendした画像配列をGIFにする。durationで持続時間、loopでループ数を指定可能。
d= imgs[0].save(path + 'out.gif',
             save_all=True, append_images=imgs[1:], optimize=False, duration=100, loop=0)
del d<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14443500424808836, 'fraction_numerical': 0.01954120645709431, 'mean_word_length': 4.306306306306307, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '649555', 'license': 'MIT', 'n_tokens_mistral': 510, 'n_tokens_neox': 483, 'n_words': 79, 'path': 'makegif.ipynb', 'repo_name': 'computational-sediment-hyd/DepthAveragedTurbulence', 'size': '1177'}