ajslater / picopt

A multi format lossless image optimizer that uses external tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mozjpeg not found crash

calumapplepie opened this issue · comments

I get the following error on any run of the program:

> picopt --help

Traceback (most recent call last):
  File "/home/calum/.local/bin/picopt", line 5, in <module>
    from picopt.cli import main
  File "/home/calum/.local/pipx/venvs/picopt/lib/python3.11/site-packages/picopt/cli.py", line 10, in <module>
    from picopt import PROGRAM_NAME, walk
  File "/home/calum/.local/pipx/venvs/picopt/lib/python3.11/site-packages/picopt/walk.py", line 16, in <module>
    from picopt.config import TIMESTAMPS_CONFIG_KEYS
  File "/home/calum/.local/pipx/venvs/picopt/lib/python3.11/site-packages/picopt/config.py", line 37, in <module>
    from picopt.handlers.jpeg import Jpeg
  File "/home/calum/.local/pipx/venvs/picopt/lib/python3.11/site-packages/picopt/handlers/jpeg.py", line 12, in <module>
    class Jpeg(ImageHandler):
  File "/home/calum/.local/pipx/venvs/picopt/lib/python3.11/site-packages/picopt/handlers/jpeg.py", line 22, in Jpeg
    PROGRAMS["mozjpeg"],
    ~~~~~~~~^^^^^^^^^^^
KeyError: 'mozjpeg'

I'm running on a Debian Stable system, without mozjpeg installed. I instaled picopt with "pipx install pipopt" about 5 minutes ago. I think there's some issue in the support for running without mozjpeg.

Appears to have been caused by the addiiton of

if not bin_path:
                    continue

in picopt/handlers/handler.py. However, due to the prevalence of squashed commits, I couldn't get the specific commit that introduced this change, and therefore couldn't easily revert it. Simply removing the lines causes picopt to try and call the "none" program for JPEGs, which is sub-optimal.

I don't want to try and spend more time prepping a patch, since its so hard to pry into the commit history.

picopt 4.0.0 should no longer crash when mozjpeg is not found.