{"record":{"id":"cd9b53b7eabff299","repo":"kovidgoyal/kitty","slug":"unexpected-output-filename-x-r-produced-by-imag","errorCode":null,"errorMessage":"Unexpected output filename: {x!r} produced by ImageMagick command: {last_imagemagick_cmd}","messagePattern":"Unexpected output filename: (.+?) produced by ImageMagick command: (.+?)","errorType":"exception","errorClass":"OutdatedImageMagick","httpStatus":null,"severity":"error","filePath":"kittens/tui/images.py","lineNumber":269,"sourceCode":"\n    with tempfile.TemporaryDirectory(dir=os.path.dirname(output_prefix)) as tdir:\n        output_template = os.path.join(tdir, f'im-%[filename:f].{m.mode}')\n        if get_multiple_frames:\n            cmd.append('+adjoin')\n        run_imagemagick(path, cmd + [output_template])\n        unseen = {x.index for x in m}\n        for x in os.listdir(tdir):\n            try:\n                parts = x.split('.', 1)[0].split('-')\n                index = int(parts[-1])\n                unseen.discard(index)\n                f = ans.frames[index]\n                f.width, f.height = map(positive_int, parts[1:3])\n                sz, pos = parts[3].split('+', 1)\n                f.canvas_width, f.canvas_height = map(positive_int, sz.split('x', 1))\n                f.canvas_x, f.canvas_y = map(int, pos.split('+', 1))\n            except Exception:\n                raise OutdatedImageMagick(f'Unexpected output filename: {x!r} produced by ImageMagick command: {last_imagemagick_cmd}')\n            f.path = output_prefix + f'-{index}.{m.mode}'\n            os.rename(os.path.join(tdir, x), f.path)\n            check_resize(f)\n    f = ans.frames[0]\n    if f.width != ans.width or f.height != ans.height:\n        with open(f.path, 'r+b') as ff:\n            data = ff.read()\n            ff.seek(0)\n            ff.truncate()\n            cd = create_canvas(data, f.width, f.canvas_x, f.canvas_y, ans.width, ans.height, 3 if ans.mode == 'rgb' else 4)\n            ff.write(cd)\n    if get_multiple_frames:\n        if unseen:\n            raise ConvertFailed(path, f'Failed to render {len(unseen)} out of {len(m)} frames of animation')\n    elif not ans.frames[0].path:\n        raise ConvertFailed(path, 'Failed to render image')\n\n    return ans","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/tui/images.py#L251-L287","documentation":"Raised (as OutdatedImageMagick) when render_image cannot parse the filename ImageMagick generated for a frame. IM names outputs like prefix-N-WxH+X+Y.mode; the code extracts width/height/canvas via split and positive_int. Any parse failure means IM emitted an unexpected naming scheme, typically from an outdated ImageMagick version.","triggerScenarios":"Calling render_image() with an ImageMagick whose identify/convert writes frame filenames in a format that doesn't match 'name-N-WxH+X+Y.ext', or where dimensions are non-positive/non-numeric, causing the parsing block to raise and be re-raised as OutdatedImageMagick.","commonSituations":"Very old ImageMagick 6.x releases; distro packages with patched filename behavior; ImageMagick forks or wrappers named 'convert' that use different output naming.","solutions":["Upgrade to a recent ImageMagick (7.x, using 'magick')","Check 'convert --version' / 'magick --version' and remove stale shims earlier in PATH","Catch OutdatedImageMagick and inform the user to update ImageMagick"],"exampleFix":"# before\nimg = render_image(path, width=80)  # OutdatedImageMagick\n# after\n# brew upgrade imagemagick  (or apt install --only-upgrade imagemagick)\nimg = render_image(path, width=80)","handlingStrategy":"try-catch","validationCode":"import subprocess\ndef imagemagick_version_ok() -> bool:\n    for exe in ('magick', 'convert'):\n        try:\n            out = subprocess.run([exe, '--version'], capture_output=True, text=True).stdout\n            if 'ImageMagick' in out:\n                return True\n        except FileNotFoundError:\n            continue\n    return False","typeGuard":null,"tryCatchPattern":"from kittens.tui.images import OutdatedImageMagick\ntry:\n    img = render_image(path, width=80)\nexcept OutdatedImageMagick:\n    show_banner('Please upgrade ImageMagick to render images')\n    img = None","preventionTips":["Pin a modern ImageMagick 7 in deployment environments","Detect IM version at startup and warn early"],"tags":["imagemagick","version-incompatibility","image-conversion"],"backgroundTag":"external-tool-version-mismatch","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}