icat.rst 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. icat
  2. ========================================
  3. .. only:: man
  4. Overview
  5. --------------
  6. *Display images in the terminal*
  7. The ``icat`` kitten can be used to display arbitrary images in the |kitty|
  8. terminal. Using it is as simple as::
  9. kitten icat image.jpeg
  10. It supports all image types supported by `ImageMagick
  11. <https://www.imagemagick.org>`__. It even works over SSH. For details, see the
  12. :doc:`kitty graphics protocol </graphics-protocol>`.
  13. You might want to create an alias in your shell's configuration files::
  14. alias icat="kitten icat"
  15. Then you can simply use ``icat image.png`` to view images.
  16. .. note::
  17. `ImageMagick <https://www.imagemagick.org>`__ must be installed for the
  18. full range of image types. Without it only PNG/JPG/GIF/BMP/TIFF/WEBP are
  19. supported.
  20. .. note::
  21. kitty's image display protocol may not work when used within a terminal
  22. multiplexer such as :program:`screen` or :program:`tmux`, depending on
  23. whether the multiplexer has added support for it or not.
  24. .. program:: kitty +kitten icat
  25. The ``icat`` kitten has various command line arguments to allow it to be used
  26. from inside other programs to display images. In particular, :option:`--place`,
  27. :option:`--detect-support` and :option:`--print-window-size`.
  28. If you are trying to integrate icat into a complex program like a file manager
  29. or editor, there are a few things to keep in mind. icat normally works by communicating
  30. over the TTY device, it both writes to and reads from the TTY. So it is
  31. imperative that while it is running the host program does not do any TTY I/O.
  32. Any key presses or other input from the user on the TTY device will be
  33. discarded. If you would instead like to use it just as a backend to generate
  34. the escape codes for image display, you need to pass it options to tell it the
  35. window dimensions, where to place the image in the window and the transfer mode
  36. to use. If you do that, it will not try to communicate with the TTY device at
  37. all. The requisite options are: :option:`--use-window-size`, :option:`--place`
  38. and :option:`--transfer-mode`, :option:`--stdin=no`.
  39. For example, to demonstrate usage without access to the TTY:
  40. .. code:: sh
  41. zsh -c 'setsid kitten icat --stdin=no --use-window-size $COLUMNS,$LINES,3000,2000 --transfer-mode=file myimage.png'
  42. Here, ``setsid`` ensures icat has no access to the TTY device.
  43. The values, 3000, 2000 are made up. They are the window width and height in
  44. pixels, to obtain which access to the TTY is needed.
  45. To be really robust you should consider writing proper support for the
  46. :doc:`kitty graphics protocol </graphics-protocol>` in the program instead.
  47. Nowadays there are many libraries that have support for it.
  48. .. include:: /generated/cli-kitten-icat.rst