{"record":{"id":"b7ceee1cc68d5b89","repo":"kovidgoyal/kitty","slug":"imagemagick-is-required-to-process-images","errorCode":null,"errorMessage":"ImageMagick is required to process images","messagePattern":"ImageMagick is required to process images","errorType":"exception","errorClass":"NoImageMagick","httpStatus":null,"severity":"error","filePath":"kittens/tui/images.py","lineNumber":130,"sourceCode":"\nclass OutdatedImageMagick(ValueError):\n    def __init__(self, detailed_error: str):\n        super().__init__('ImageMagick on this system is too old ImageMagick 7+ required which was first released in 2016')\n        self.detailed_error = detailed_error\n\n\nlast_imagemagick_cmd: Sequence[str] = ()\n\n\ndef run_imagemagick(path: str, cmd: Sequence[str], keep_stdout: bool = True) -> 'CompletedProcess[bytes]':\n    global last_imagemagick_cmd\n    import subprocess\n\n    last_imagemagick_cmd = cmd\n    try:\n        p = subprocess.run(cmd, stdout=subprocess.PIPE if keep_stdout else subprocess.DEVNULL, stderr=subprocess.PIPE)\n    except FileNotFoundError:\n        raise NoImageMagick('ImageMagick is required to process images')\n    if p.returncode != 0:\n        raise OpenFailed(path, p.stderr.decode('utf-8'))\n    return p\n\n\ndef identify(path: str) -> ImageData:\n    import json\n\n    q = (\n        '{\"fmt\":\"%m\",\"canvas\":\"%g\",\"transparency\":\"%A\",\"gap\":\"%T\",\"index\":\"%p\",\"size\":\"%wx%h\",'\n        '\"dpi\":\"%xx%y\",\"dispose\":\"%D\",\"orientation\":\"%[EXIF:Orientation]\"},'\n    )\n    exe = which('magick')\n    if exe:\n        cmd = [exe, 'identify']\n    else:\n        cmd = ['identify']\n    p = run_imagemagick(path, cmd + ['-format', q, '--', path])","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/tui/images.py#L112-L148","documentation":"Raised (as NoImageMagick) by run_imagemagick when executing the ImageMagick command fails with FileNotFoundError, meaning neither 'magick' nor 'convert' was found in PATH. All image operations in this module (identify, render_image) shell out to ImageMagick, so the dependency is mandatory.","triggerScenarios":"Calling identify(path) or render_image(...) on a machine where ImageMagick is not installed or its bin directory is not in PATH for the kitten's process.","commonSituations":"Fresh container/CI image without ImageMagick; macOS where 'magick' is not symlinked; PATH stripped by a service manager, sandbox, or GUI-launched kitty that doesn't inherit the shell PATH.","solutions":["Install ImageMagick (apt install imagemagick / brew install imagemagick) and verify 'magick' or 'convert' is on PATH","If installed but not found, ensure kitty is launched from an environment with the correct PATH or symlink magick into a standard bin dir","Catch NoImageMagick and degrade gracefully (skip image preview)"],"exampleFix":"# before\nimg = render_image(path, width=80)  # NoImageMagick\n# after\n# sudo apt-get install imagemagick   (or brew install imagemagick)\nimg = render_image(path, width=80)","handlingStrategy":"validation","validationCode":"import shutil\ndef imagemagick_available() -> bool:\n    return shutil.which('magick') is not None or shutil.which('convert') is not None","typeGuard":null,"tryCatchPattern":"from kittens.tui.images import NoImageMagick\ntry:\n    img = render_image(path, width=80)\nexcept NoImageMagick:\n    img = None  # image previews unsupported here","preventionTips":["Check for magick/convert at app startup","Install ImageMagick in Dockerfiles/CI images","Catch NoImageMagick separately from ConvertFailed"],"tags":["imagemagick","missing-dependency","path","kitty"],"backgroundTag":"missing-external-dependency","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}