前提・実現したいこと
フォルダ内のpngファイルをGIFにしたい。
発生している問題・エラーメッセージ
エラーメッセージ
ValueError Traceback (most recent call last)
<ipython-input-23-a14c2c5be5f7> in <module>
5 images = list(map(lambda file: Image.open(file), files))
6
----> 7 images[0].save('out.gif', save_all=True, append_images=images[1:], duration=400, loop=0)
/usr/local/Caskroom/miniconda/base/envs/x86_tenso_env/lib/python3.7/site-packages/PIL/Image.py in save(self, fp, format, **params)
2233
2234 try:
-> 2235 save_handler(self, fp, filename)
2236 finally:
2237 # do what we can to clean up
/usr/local/Caskroom/miniconda/base/envs/x86_tenso_env/lib/python3.7/site-packages/PIL/GifImagePlugin.py in _save_all(im, fp, filename)
522
523 def _save_all(im, fp, filename):
--> 524 _save(im, fp, filename, save_all=True)
525
526
/usr/local/Caskroom/miniconda/base/envs/x86_tenso_env/lib/python3.7/site-packages/PIL/GifImagePlugin.py in _save(im, fp, filename, save_all)
533 im.encoderinfo["optimize"] = im.encoderinfo.get("optimize", True)
534
--> 535 if not save_all or not _write_multiple_frames(im, fp, palette):
536 _write_single_frame(im, fp, palette)
537
/usr/local/Caskroom/miniconda/base/envs/x86_tenso_env/lib/python3.7/site-packages/PIL/GifImagePlugin.py in _write_multiple_frames(im, fp, palette)
512 im_frame = im_frame.crop(frame_data["bbox"])
513 offset = frame_data["bbox"][:2]
--> 514 _write_frame_data(fp, im_frame, offset, frame_data["encoderinfo"])
515 return True
516 elif "duration" in im.encoderinfo and isinstance(
/usr/local/Caskroom/miniconda/base/envs/x86_tenso_env/lib/python3.7/site-packages/PIL/GifImagePlugin.py in _write_frame_data(fp, im_frame, offset, params)
828
829 # local image header
--> 830 _write_local_header(fp, im_frame, offset, 0)
831
832 ImageFile._save(
/usr/local/Caskroom/miniconda/base/envs/x86_tenso_env/lib/python3.7/site-packages/PIL/GifImagePlugin.py in _write_local_header(fp, im, offset, flags)
559 pass
560 else:
--> 561 transparency = int(transparency)
562 # optimize the block away if transparent color is not used
563 transparent_color_exists = True
ValueError: invalid literal for int() with base 10: b'\x00m\x8a\t!4\xd5\x1c\xfe\xab\xf9\xf4\xdc\xbeGV\xc1^\xa0\xcf}\xd9\x7fb\xe4=\xb2D\xaa\xda\xee\xc3\xeb\x9a\xd4\x8cG\xa8^td\xe3\xee{\xc0\x8c\x92'
該当のソースコード
python
1from PIL import Image 2import glob 3 4files = sorted(glob.glob('/Users/440h/analysis/AAA/*.png')) 5images = list(map(lambda file: Image.open(file), files)) 6 7images[0].save('out.gif', save_all=True, append_images=images[1:], duration=400, loop=0)
#filesの実行結果 ['/Users/440h/analysis/AAA/a.png', '/Users/440h/analysis/AAA/b.png', '/Users/440h/analysis/AAA/c.png', '/Users/440h/analysis/AAA/d.png']
回答1件
あなたの回答
tips
プレビュー