Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Can't use gif-for-cli (Float division by zero on execute.py) #33

Open
larkjkj opened this issue Jun 20, 2023 · 6 comments
Open

Can't use gif-for-cli (Float division by zero on execute.py) #33

larkjkj opened this issue Jun 20, 2023 · 6 comments

Comments

@larkjkj
Copy link

larkjkj commented Jun 20, 2023

archlinux :: ~/Projects/gif-for-cli ‹master*› » gif-for-cli
Traceback (most recent call last):
File "/home/lark/.local/bin/gif-for-cli", line 33, in
sys.exit(load_entry_point('gif-for-cli==1.1.2', 'console_scripts', 'gif-for-cli')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lark/.local/lib/python3.11/site-packages/gif_for_cli-1.1.2-py3.11.egg/gif_for_cli/main.py", line 23, in main
execute(os.environ, sys.argv[1:], sys.stdout)
File "/home/lark/.local/lib/python3.11/site-packages/gif_for_cli-1.1.2-py3.11.egg/gif_for_cli/execute.py", line 94, in execute
seconds_per_frame=config['seconds'] / config['num_frames'],
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero

@FrancoCorleone
Copy link

I have exactly the same problem, any workarounds?

@SASUPERNOVA
Copy link

SASUPERNOVA commented Sep 29, 2023

@FrancoCorleone You could manually edit gif_for_cli/generate/__init__.py to add my fixes Add missing "rows" option in _save_config and Add fallback regex method to _run_ffmpeg. If you are on arch, the files should be in ~/.local/lib/python3.11/site-packages/gif_for_cli-1.1.2-py3.11.egg/. If not, check the path in your error message.

Edit: If you don't feel like manually editing, you could also replace gif_for_cli/generate/__init__.py with the one from my repo.

@Cephir23
Copy link

Same issue here.

[cephir@archlinux]$ gif-for-cli
Traceback (most recent call last):
File "/home/cephir/.local/bin/gif-for-cli", line 8, in
sys.exit(main())
^^^^^^
File "/home/cephir/.local/lib/python3.11/site-packages/gif_for_cli/main.py", line 23, in main
execute(os.environ, sys.argv[1:], sys.stdout)
File "/home/cephir/.local/lib/python3.11/site-packages/gif_for_cli/execute.py", line 94, in execute
seconds_per_frame=config['seconds'] / config['num_frames'],
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero

I tried replacing gif_for_cli/generate/init.py with the one from your repo, but it doesn't work for me.

@SASUPERNOVA
Copy link

@Cephir23 That may be because you have already used the bugged version of gif-for-cli. When gif-for-cli reads a GIF, it creates a cache directory for the image where it places a config.json, which contains num_frames. Once that config is created, it will remain the same on each execution, so num_frames should still be 0, causing a divide by zero error. On my system (probably yours as well since you use Arch), the cache directory is ~/.cache/gif-for-cli/1.1.2. If there are any directories in the cache, try removing them and rerunning gif-for-cli.

@Cephir23
Copy link

@Cephir23 That may be because you have already used the bugged version of gif-for-cli. When gif-for-cli reads a GIF, it creates a cache directory for the image where it places a config.json, which contains num_frames. Once that config is created, it will remain the same on each execution, so num_frames should still be 0, causing a divide by zero error. On my system (probably yours as well since you use Arch), the cache directory is ~/.cache/gif-for-cli/1.1.2. If there are any directories in the cache, try removing them and rerunning gif-for-cli.

Worked! Thank you so much.

@Lepidos
Copy link

Lepidos commented Jan 13, 2024

num_fames is on: gif_for_cli/generate/init.py

just replace it

  • num_frames = int(re.search(r'frame=\s*(\d+)', err).group(1))
  • num_frames = len(glob.glob1('{}/'.format(output_dirnames['jpg']),"*.jpg"))

https://github.com/Lepidos/gif-for-cli/blob/master/gif_for_cli/generate/__init__.py

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants