kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.15k stars 972 forks source link

icat kitten ValueError #3384

Closed amanjitsk closed 3 years ago

amanjitsk commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Download this image as gruvbox.png gruvbox

  2. Run kitty +kitten icat gruvbox.png

  3. See this error

    Traceback (most recent call last):
    File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 133, in <module>
    main()
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 124, in main
    namespaced(['+', first_arg[1:]] + sys.argv[2:])
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 81, in namespaced
    func(args[1:])
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 71, in run_kitten
    rk(kitten)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/runner.py", line 106, in run_kitten
    runpy.run_module('kittens.{}.main'.format(kitten), run_name=run_name)
    File "/usr/lib/python3.8/runpy.py", line 210, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
    File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 579, in <module>
    main()
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 559, in main
    process_single_item(item, cli_opts, parsed_opts, url_pat)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 487, in process_single_item
    file_removed = process(item, args, parsed_opts, is_tempfile)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 337, in process
    outfile, width, height = render_as_single_image(path, m, available_width, available_height, args.scale_up)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/tui/images.py", line 262, in render_as_single_image
    result = render_image(path, output, m, available_width, available_height, scale_up, only_first_frame=True)
    File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/tui/images.py", line 230, in render_image
    sz, pos = parts[3].split('+', 1)
    ValueError: not enough values to unpack (expected 2, got 1)

Expected behavior The image should be displayed

Environment details OS: Ubuntu 20.04 LTS

kitty 0.19.3 (82934b84d6) created by Kovid Goyal
Linux kirpadhar 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64
Ubuntu 20.04.2 LTS \n \l
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
Loaded config files: /home/username/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
active_border_color        Color(red=143, green=188, blue=187)
active_tab_background      Color(red=143, green=188, blue=187)
active_tab_foreground      Color(red=46, green=52, blue=64)
allow_remote_control       y
background                 Color(red=46, green=52, blue=64)
bell_border_color          Color(red=191, green=97, blue=106)
bold_font                  Iosevka Bold Nerd Font Complete
bold_italic_font           Iosevka Bold Italic Nerd Font Complete
clipboard_control          frozenset({'write-primary', 'write-clipboard', 'no-append'})
color0                     Color(red=46, green=52, blue=64)
color1                     Color(red=191, green=97, blue=106)
color10                    Color(red=163, green=190, blue=140)
color11                    Color(red=208, green=135, blue=112)
color12                    Color(red=94, green=129, blue=172)
color13                    Color(red=180, green=142, blue=173)
color14                    Color(red=136, green=192, blue=208)
color15                    Color(red=236, green=239, blue=244)
color2                     Color(red=163, green=190, blue=140)
color3                     Color(red=235, green=203, blue=139)
color4                     Color(red=129, green=161, blue=193)
color5                     Color(red=180, green=142, blue=173)
color6                     Color(red=143, green=188, blue=187)
color7                     Color(red=216, green=222, blue=233)
color8                     Color(red=67, green=76, blue=94)
color9                     Color(red=191, green=97, blue=106)
cursor                     Color(red=229, green=233, blue=240)
dynamic_background_opacity True
enable_audio_bell          False
enabled_layouts            ['splits:split_axis=horizontal', 'grid', 'fat:bias=65', 'tall:bias=65', 'stack', 'horizontal', 'vertical']
font_family                Iosevka Medium Nerd Font Complete
font_size                  13.0
foreground                 Color(red=216, green=222, blue=233)
inactive_border_color      Color(red=46, green=52, blue=64)
inactive_tab_background    Color(red=46, green=52, blue=64)
inactive_tab_foreground    Color(red=216, green=222, blue=233)
initial_window_height      (500, 'px')
italic_font                Iosevka Italic Nerd Font Complete
kitty_mod                  2
remember_window_size       False
scrollback_lines           10000
selection_background       Color(red=216, green=222, blue=233)
selection_foreground       Color(red=46, green=52, blue=64)
shell                      zsh
tab_title_template         {index}: {title}
url_color                  Color(red=235, green=203, blue=139)
url_style                  2
window_border_width        (1.5, 'pt')
window_padding_width       FloatEdges(left=10.0, top=10.0, right=10.0, bottom=10.0)
Added shortcuts:
     f11 KeyAction(func='kitten', args=['zoom_toggle.py', 'stack'])
     alt+\ KeyAction(func='kitten', args=['zoom_toggle.py', 'splits:split_axis=horizontal'])
     alt+a > h KeyAction(func='neighboring_window', args=['left'])
     alt+a > j KeyAction(func='neighboring_window', args=['bottom'])
     alt+a > k KeyAction(func='neighboring_window', args=['top'])
     alt+a > r KeyAction(func='layout_action', args=['rotate', ()])
     alt+a > enter KeyAction(func='launch', args=['--location=vsplit', '--cwd=current', 'xlaunch'])
     alt+a > shift+h KeyAction(func='move_window', args=['left'])
     alt+a > shift+j KeyAction(func='move_window', args=['bottom'])
     alt+a > shift+k KeyAction(func='move_window', args=['top'])
     alt+a > shift+l KeyAction(func='move_window', args=['right'])
     alt+a > shift+enter KeyAction(func='launch', args=['--location=hsplit', '--cwd=current', 'xlaunch'])
     alt+b > 0 KeyAction(func='set_background_opacity', args=['0'])
     alt+b > 1 KeyAction(func='set_background_opacity', args=['1'])
     alt+b > d KeyAction(func='set_background_opacity', args=['default'])
     alt+b > j KeyAction(func='set_background_opacity', args=['-0.1'])
     alt+b > k KeyAction(func='set_background_opacity', args=['+0.1'])
     alt+d KeyAction(func='scroll_page_down', args=())
     alt+g > f KeyAction(func='kitten', args=['hints', '--type path --program -'])
     alt+g > h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
     alt+g > l KeyAction(func='kitten', args=['hints', '--type line --program -'])
     alt+g > u KeyAction(func='kitten', args=['hints', '--url-prefixes file,ftp,http,https,www'])
     alt+g > w KeyAction(func='kitten', args=['hints', '--type word --program -'])
     alt+g > shift+f KeyAction(func='kitten', args=['hints', '--type path'])
     alt+g > shift+u KeyAction(func='kitten', args=['unicode_input'])
     alt+m KeyAction(func='detach_window', args=('ask',))
     alt+p KeyAction(func='paste_from_selection', args=())
     alt+tab KeyAction(func='nth_window', args=[-1])
     alt+print_screen KeyAction(func='launch', args=['--stdin-source=@screen', '--stdin-add-formatting', '--type=clipboard'])
     alt+menu KeyAction(func='next_layout', args=())
     shift+alt+, KeyAction(func='move_window_backward', args=())
     shift+alt+. KeyAction(func='move_window_forward', args=())
     shift+alt+/ KeyAction(func='launch', args=['--type=tab', 'nvim', '/home/username/.config/kitty/kitty.conf'])
     shift+alt+[ KeyAction(func='move_tab_backward', args=())
     shift+alt+\ KeyAction(func='kitten', args=['zoom_toggle.py', 'tall:bias=65'])
     shift+alt+] KeyAction(func='move_tab_forward', args=())
     shift+alt+d KeyAction(func='change_font_size', args=(True, '-', 2.0))
     shift+alt+j KeyAction(func='change_font_size', args=(True, '-', 1.0))
     shift+alt+k KeyAction(func='change_font_size', args=(True, '+', 1.0))
     shift+alt+m KeyAction(func='detach_tab', args=('ask',))
     shift+alt+n KeyAction(func='launch', args=['--type=os-window', 'xlaunch'])
     shift+alt+r KeyAction(func='set_tab_title', args=())
     shift+alt+s KeyAction(func='launch', args=['--stdin-source=@screen_scrollback', '--stdin-add-formatting', '--type=window', 'nvim'])
     shift+alt+t KeyAction(func='launch', args=['--type=tab', '--cwd=current', 'xlaunch'])
     shift+alt+u KeyAction(func='change_font_size', args=(True, '+', 2.0))
     shift+alt+w KeyAction(func='close_tab', args=())
     shift+alt+enter KeyAction(func='launch', args=['--location=hsplit', '--cwd=current'])
     shift+alt+delete KeyAction(func='clear_terminal', args=['reset', True])
     shift+alt+left KeyAction(func='move_window', args=['left'])
     shift+alt+right KeyAction(func='move_window', args=['right'])
     shift+alt+up KeyAction(func='move_window', args=['top'])
     shift+alt+down KeyAction(func='move_window', args=['bottom'])
     shift+alt+home KeyAction(func='change_font_size', args=(True, None, 0.0))
Removed shortcuts:
     alt+b KeyAction(func='move_window_backward', args=())
     alt+f KeyAction(func='move_window_forward', args=())
     alt+h KeyAction(func='show_scrollback', args=())
     alt+l KeyAction(func='next_layout', args=())
     alt+p > f KeyAction(func='kitten', args=['hints', '--type path --program -'])
     alt+p > h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
     alt+p > l KeyAction(func='kitten', args=['hints', '--type line --program -'])
     alt+p > n KeyAction(func='kitten', args=['hints', '--type linenum'])
     alt+p > w KeyAction(func='kitten', args=['hints', '--type word --program -'])
     alt+p > y KeyAction(func='kitten', args=['hints', '--type hyperlink'])
     alt+p > shift+f KeyAction(func='kitten', args=['hints', '--type path'])
     alt+f11 KeyAction(func='toggle_fullscreen', args=())
Changed shortcuts:
     alt+, KeyAction(func='previous_window', args=())
     alt+- KeyAction(func='kitten', args=['zoom_toggle.py', 'fat:bias=65'])
     alt+. KeyAction(func='next_window', args=())
     alt+0 KeyAction(func='goto_tab', args=(10,))
     alt+1 KeyAction(func='goto_tab', args=(1,))
     alt+2 KeyAction(func='goto_tab', args=(2,))
     alt+3 KeyAction(func='goto_tab', args=(3,))
     alt+4 KeyAction(func='goto_tab', args=(4,))
     alt+5 KeyAction(func='goto_tab', args=(5,))
     alt+6 KeyAction(func='goto_tab', args=(6,))
     alt+7 KeyAction(func='goto_tab', args=(7,))
     alt+8 KeyAction(func='goto_tab', args=(8,))
     alt+9 KeyAction(func='goto_tab', args=(9,))
     alt+= KeyAction(func='kitten', args=['zoom_toggle.py', 'grid'])
     alt+[ KeyAction(func='previous_tab', args=())
     alt+] KeyAction(func='next_tab', args=())
     alt+` KeyAction(func='goto_tab', args=(0,))
     alt+a > l KeyAction(func='neighboring_window', args=['right'])
     alt+s KeyAction(func='launch', args=['--stdin-source=@screen_scrollback', '--stdin-add-formatting', '--type=overlay', 'less'])
     alt+t KeyAction(func='launch', args=['--type=tab', '--cwd=current'])
     alt+u KeyAction(func='scroll_page_up', args=())
     alt+enter KeyAction(func='launch', args=['--location=vsplit', '--cwd=current'])
     alt+delete KeyAction(func='combine', args=(KeyAction(func='clear_terminal', args=['scrollback', True]), KeyAction(func='send_text', args=['normal,application', b'\x0c'])))
     alt+left KeyAction(func='neighboring_window', args=['left'])
     alt+right KeyAction(func='neighboring_window', args=['right'])
     alt+up KeyAction(func='neighboring_window', args=['top'])
     alt+down KeyAction(func='neighboring_window', args=['bottom'])
kovidgoyal commented 3 years ago

Works fine for me, that error indicates imagemagick on your system is producing unexpected output, what version of ImageMagick are you on?

amanjitsk commented 3 years ago

Thanks for the super quick reply image

kovidgoyal commented 3 years ago

Ah yes, its quite likely the new code needed to handle animated images will only work with ImageMagick version 7+. If you can update ImageMagick do so, otherwise I just made a commit that will show a more useful error message. Try it and post the error and I will see if I can workaround.

amanjitsk commented 3 years ago

Ah thanks just tried it out. Here's the new error

Traceback (most recent call last):
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/tui/images.py", line 234, in render_image
    f = ans.frames[index]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 133, in <module>
    main()
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 124, in main
    namespaced(['+', first_arg[1:]] + sys.argv[2:])
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 81, in namespaced
    func(args[1:])
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../__main__.py", line 71, in run_kitten
    rk(kitten)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/runner.py", line 106, in run_kitten
    runpy.run_module('kittens.{}.main'.format(kitten), run_name=run_name)
  File "/usr/lib/python3.8/runpy.py", line 210, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 579, in <module>
    main()
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 559, in main
    process_single_item(item, cli_opts, parsed_opts, url_pat)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 487, in process_single_item
    file_removed = process(item, args, parsed_opts, is_tempfile)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/icat/main.py", line 337, in process
    outfile, width, height = render_as_single_image(path, m, available_width, available_height, args.scale_up)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/tui/images.py", line 270, in render_as_single_image
    result = render_image(path, output, m, available_width, available_height, scale_up, only_first_frame=True)
  File "/home/username/pkgs/kovidgoyal---kitty/kitty/launcher/../../kittens/tui/images.py", line 240, in render_image
    raise ValueError(f'Unexpected output filename: {x!r} produced by ImageMagick command: {last_imagemagick_cmd}')
ValueError: Unexpected output filename: 'im-1888-7900.rgba' produced by ImageMagick command: ['/usr/bin/convert', '-background', 'none', '--', 'gruvbox.png', '-resize', '1888x790!', '-depth', '8', '-set', 'filename:f', '%w-%h-%g', '/tmp/tmpt4enl385/im-%[filename:f]-%d.rgba']
kovidgoyal commented 3 years ago

Yup, that's a bug in ImageMagick on your system.

convert -background none -- gruvbox.png -resize '1888x790!' -depth 8 -set 'filename:f' '%w-%h-%g' 'im-%[filename:f]-%d.rgba'

should produce a file named

im-1888-790-1888x790+0+0-0.rgba

instead it is producing a file named

im-1888-7900.rgba

it has ignored the %g part of the filename spec.

I suggest you stay with kitty 0.19.3 or update ImageMagick, ImageMagick 7 was released almost five years ago.