Skip to content

Probe -c targets that an enabled format converts to - #147

Merged
ajslater merged 1 commit into
developfrom
claude/recursing-tu-a34c10
Oct 4, 2026
Merged

ajslater merged 1 commit into
developfrom
claude/recursing-tu-a34c10

Conversation

@ajslater

@ajslater ajslater commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Problem

picopt -x RAR -c ZIP converted nothing unless ZIP was also passed to -x. Config probed only handlers whose own formats were enabled, so Zip never reached handler_stages, and the repack pass found no available target. Every convert-only route had the same gap: 7Z and TAR/TGZ/TBZ/TXZ to ZIP, CBR/CB7/CBT to CBZ, and image routes like -f BMP -c PNG or -f GIF -c JXL. picopt doctor -x RAR -c ZIP reported FAIL RAR -c ZIP needs -x ZIP.

Fix

  • enabled_handler_classes(formats, convert_to) in picopt/config/handlers.py also probes each convert-chain handler of an enabled format whose output is a -c target.
  • The doctor uses that same function instead of its own copy of the scope check. Its "needs -x" message can now only appear for the opt-in JXL flags, and it names the missing source format. -f PNG -c JXL --convert-jpeg-to-jxl used to say needs -x JXL, which wouldn't help; it now says JxlFromJpeg needs -x JPEG.
  • JxlLossless no longer lists PNG in INPUT_FILE_FORMATS; it was only there to get the handler probed. A PNG run without -c JXL no longer probes the JXL encoder.
  • README: the per-directory example drops CBZ from -x. The other examples keep CBZ because they also optimize existing CBZ files.

This doesn't interfere with the #145 stand-ins: a stand-in writes the input's own format, so the existing rule already probes it.

Tests

  • test_convert_target_must_be_enabled is now test_convert_target_needs_no_extra_format.
  • New tests cover the opt-in "needs -x JPEG" wording and config probing for -x RAR -c ZIP and -f BMP -c PNG.
  • Removed the -x ...,ZIP workaround from four tests, so the tar→ZIP and per-directory CBR→CBZ tests now exercise the fix end to end.
  • All six new or changed tests fail on the old code.

make fix, make lint and make ty are clean. make test: 439 passed, 6 skipped (PDF render checks).

🤖 Generated with Claude Code

`-x RAR -c ZIP` converted nothing unless ZIP was also enabled: config
probed only handlers whose own formats were enabled, so Zip never reached
handler_stages and the repack pass found no available target. The same
gap hit every convert-only route (`-f BMP -c PNG`, `-f GIF -c JXL`, 7z and
tar to zip, CBR/CB7/CBT to CBZ).

Config now also probes each convert-chain handler of an enabled format
whose output is a -c target. The doctor shares that scope instead of
copying it, and its "needs -x" now names the source format an opt-in
conversion is missing. JxlLossless no longer lists PNG as an input just to
be probed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ajslater
ajslater merged commit 2cfa318 into develop Oct 4, 2026
7 checks passed
@ajslater
ajslater deleted the claude/recursing-tu-a34c10 branch October 4, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant