pax_global_header00006660000000000000000000000064141663630370014523gustar00rootroot0000000000000052 comment=8b5023cc1506e18e8e18d4bd6d687a0eff70134f timg-1.4.3/000077500000000000000000000000001416636303700124705ustar00rootroot00000000000000timg-1.4.3/.editorconfig000066400000000000000000000002371416636303700151470ustar00rootroot00000000000000root = true [*] charset = utf-8 trim_trailing_whitespace = true end_of_line = lf insert_final_newline = true [*.{cc,h}] indent_style = space indent_size = 4 timg-1.4.3/.github/000077500000000000000000000000001416636303700140305ustar00rootroot00000000000000timg-1.4.3/.github/workflows/000077500000000000000000000000001416636303700160655ustar00rootroot00000000000000timg-1.4.3/.github/workflows/macos-brew.yml000066400000000000000000000005771416636303700206600ustar00rootroot00000000000000 name: macOS Brew Building HEAD on: push: branches: - main jobs: install_dependencies_and_build: name: Build and test formula runs-on: macos-latest steps: - name: Run everything run: | brew update brew install --only-dependencies --HEAD timg brew install --build-from-source --HEAD timg brew test timg timg-1.4.3/.github/workflows/macos.yml000066400000000000000000000014131416636303700177110ustar00rootroot00000000000000name: macOS Build on: push: branches: - main pull_request: jobs: install_dependencies_and_build: name: Install Dependencies and Build runs-on: macos-latest steps: - name: Prepare environment and install dependencies run: | brew update brew install GraphicsMagick webp cmake brew install ffmpeg jpeg-turbo libexif libpng brew install openslide brew install pandoc brew unlink jpeg brew link --force jpeg-turbo - name: Get the Source uses: actions/checkout@v2 - name: Build timg run: | mkdir build cd build cmake .. -DWITH_VIDEO_DECODING=On -DWITH_VIDEO_DEVICE=On -DWITH_OPENSLIDE_SUPPORT=On make -k timg-1.4.3/.github/workflows/ubuntu.yml000066400000000000000000000025001416636303700201270ustar00rootroot00000000000000 name: Ubuntu Build on: push: branches: - main pull_request: jobs: install_dependencies_and_build: name: Install Dependencies and Build runs-on: ubuntu-latest steps: - name: Install minimal dependencies run: | sudo apt install cmake git g++ pkg-config libswscale-dev libavutil-dev - name: Get the Source uses: actions/checkout@v2 - name: Build minimal dependency timg # Building a timg with all dependencies removed to the point that it # can't display anything. Makes sure all the #ifdefs are there. run: | mkdir build-limitdep cd build-limitdep cmake .. -DWITH_VIDEO_DECODING=Off -DWITH_VIDEO_DEVICE=Off -DWITH_OPENSLIDE_SUPPORT=Off -DWITH_GRAPHICSMAGICK=Off -DWITH_TURBOJPEG=Off make -k - name: Install Full Dependencies run: | sudo apt install libgraphicsmagick++-dev sudo apt install libturbojpeg-dev libexif-dev sudo apt install libavcodec-dev libavformat-dev libavdevice-dev sudo apt install libopenslide-dev sudo apt install pandoc - name: Build Full timg run: | mkdir build cd build cmake .. -DWITH_VIDEO_DECODING=On -DWITH_VIDEO_DEVICE=On -DWITH_OPENSLIDE_SUPPORT=On make -k timg-1.4.3/.gitignore000066400000000000000000000000141416636303700144530ustar00rootroot00000000000000*.o *~ timg timg-1.4.3/CMakeLists.txt000066400000000000000000000047441416636303700152410ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.10) project(timg VERSION 1.4.3 LANGUAGES CXX) option(WITH_VIDEO_DECODING "Enables video decoding feature" ON) option(WITH_VIDEO_DEVICE "Enables reading videos from devices e.g. v4l2 (requires WITH_VIDEO_DECODING)" ON) option(WITH_OPENSLIDE_SUPPORT "Enables support to scientific OpenSlide formats" OFF) # Options that should be typically on, but could be disabled for special # applications where less dependencies are required option(WITH_GRAPHICSMAGICK "Enable general image loading with Graphicsmagick. You typically want this." ON) option(WITH_TURBOJPEG "Optimized JPEG loading. You typically want this." ON) option(WITH_TERMINAL_QUERY "Query terminals for availability of kitty/iterm capabilities and background color. If not compiled in, choose with -p (pixelation) and -b (background)" ON) option(WITH_STB_IMAGE "Use STB image, a self-contained albeit limited image loading and lower quality. Use if WITH_GRAPHICSMAGICK is not possible and want to limit dependencies." OFF) # Note: The version string can be ammended with -DDISTRIBUTION_VERSION, see src/timg-version.h.in option(TIMG_VERSION_FROM_GIT "Get the program version from the git repository" ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(FindPkgConfig) include(GNUInstallDirs) if(TIMG_VERSION_FROM_GIT) find_package(Git REQUIRED) include(GetGitRevisionDescription) endif() pkg_check_modules(ZLIB REQUIRED IMPORTED_TARGET zlib) if(WITH_TURBOJPEG) pkg_check_modules(TURBOJPEG REQUIRED IMPORTED_TARGET libturbojpeg) pkg_check_modules(EXIF REQUIRED IMPORTED_TARGET libexif) pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil) pkg_check_modules(SWSCALE IMPORTED_TARGET REQUIRED libswscale) endif() if(WITH_GRAPHICSMAGICK) pkg_check_modules(GRAPHICSMAGICKXX IMPORTED_TARGET REQUIRED GraphicsMagick++) endif() if(WITH_OPENSLIDE_SUPPORT) pkg_check_modules(OPENSLIDE IMPORTED_TARGET REQUIRED openslide) pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil) pkg_check_modules(SWSCALE IMPORTED_TARGET REQUIRED libswscale) endif() if(WITH_VIDEO_DECODING) pkg_check_modules(LIBAV IMPORTED_TARGET REQUIRED libavcodec libavutil libavformat) pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil) pkg_check_modules(SWSCALE IMPORTED_TARGET REQUIRED libswscale) if (WITH_VIDEO_DEVICE) pkg_check_modules(LIBAV_DEVICE IMPORTED_TARGET REQUIRED libavdevice) endif() endif() find_package(Threads) add_subdirectory(src) add_subdirectory(man) timg-1.4.3/LICENSE000066400000000000000000000432541416636303700135050ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. timg-1.4.3/README.md000066400000000000000000000575741416636303700137710ustar00rootroot00000000000000timg - Terminal Image and Video Viewer ====================================== [![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://github.com/hzeller/timg/blob/main/LICENSE)   [![Ubuntu Build](../../workflows/Ubuntu%20Build/badge.svg)](../../actions?query=workflow%3A"Ubuntu+Build") [![macOS Build](../../workflows/macOS%20Build/badge.svg)](../../actions?query=workflow%3A"macOS+Build") [![macOS Brew Building HEAD](../../workflows/macOS%20Brew%20Building%20HEAD/badge.svg)](../../actions?query=workflow%3A"macOS+Brew+Building+HEAD") ### https://timg.sh/ A user-friendly viewer that uses 24-Bit color capabilities and unicode character blocks to display images, animations and videos in the terminal. On terminals that implement the [Kitty Graphics Protocol] or the [iTerm2 Graphics Protocol] this displays images in full resolution. ![](./img/sunflower-term.png) Displays regular images, plays animated gifs, scrolls static images and plays videos. Useful if you want to have a quick visual check without leaving the comfort of your shell and having to start a bulky image viewer. Sometimes this is the only way if your terminal is connected remotely via ssh. And of course if you don't need the resolution. While icons typically fit pixel-perfect, larger images are scaled down to match the resolution. The command line accepts any number of image/video filenames that it shows in sequence one per page or in a grid in multiple columns, depending on your choice of `--grid`. The output is emitted in-line with minimally messing with your terminal, so you can simply go back in history using your terminals' scroll-bar (Or redirecting the output to a file allows you to later simply `cat` that file to your terminal. Even `less -R` seems to be happy with it). #### Pixelation On a regular terminal, block-characters are used to output images. Half blocks present pixels color-accurately, and quarter blocks provide a higher spatial resolution at the expense of slightly worse color accuracy. These modes should be compatible with most common terminals that support UTF8 and 24Bit color. If you are on a [Kitty][Kitty Graphics Protocol], [iTerm2], or [wezterm] terminal, images can be shown in full resolution. -p half | -p quarter | -p kitty or -p iterm2 | ---------|-----------------------|-----------------------------------| ![](img/pixelation-half.png) | ![](img/pixelation-quarter.png) | ![](img/pixelation-kitty.png) | #### Grid display Images can be shown in a grid, which is very useful if you quickly want to sieve through a lot of images. You can choose to show the filename as title, so it is easy to find exactly the filename you're looking for (The following grid uses `--grid=2` and is pixelated with `-pq`). ![Grid view of 4 pictures](./img/grid-timg.png)
This is how the same grid looks with Kitty or iTerm2 Graphics mode... ![](img/grid-timg-wezterm.png)
### Synopsis ``` usage: timg [options] [...] Options: -gx : Output geometry in character cells. Partial geometry leaving out one value -gx or -gx is possible, the other value it then derived from the terminal size. Default derived from terminal size is 160x50 -p : Pixelation: 'h' = half blocks 'q' = quarter blocks 'k' = kitty graphics 'i' = iTerm2 graphics Default: Auto-detect graphics, otherwise 'quarter'. --compress : Only for -pk or -pi: Compress image data. More CPU use for timg, but less bandwidth needed. -C, --center : Center image horizontally. -W, --fit-width: Scale to fit width of available space, even if it exceeds height. --grid=[x] : Arrange images in a grid (contact sheet). -w : Wait time between images (default: 0.0). -a : Switch off anti aliasing (default: on). -b : Background color to use behind alpha channel. Format 'yellow', '#rrggbb', 'auto' or 'none' (default 'auto'). -B : Checkerboard pattern color to use on alpha. --pattern-size= : Integer factor scale of the checkerboard pattern. --auto-crop[=] : Crop away all same-color pixels around image. The optional pre-crop is the width of border to remove beforehand to get rid of an uneven border. --rotate= : Rotate according to included exif orientation. or 'off'. Default: exif. --clear : Clear screen first. Optional argument 'every' will clear before every image (useful with -w) -U, --upscale[=i]: Allow Upscaling. If an image is smaller than the available frame (e.g. an icon), enlarge it to fit. Optional parameter 'i' only enlarges in integer steps. -V : Directly use Video subsystem. Don't probe image decoding first (useful, if you stream video from stdin) -I : Only use Image subsystem. Don't attempt video decoding --title[=]: Print title above each image. Accepts the following format parameters: %f = full filename; %b = basename %w = image width; %h = height %D = internal decoder used If no parameter is given, defaults to "%f" -F : Print filename as title. Behaves like --title="%f" -f : Read newline-separated list of image files to show. (Can be provided multiple times.) -o : Write to instead of stdout. -E : Don't hide the cursor while showing images. --threads= : Run image decoding in parallel with n threads (Default 2, half #cores on this machine) --color8 : Choose 8 bit color mode for -ph or -pq --version : Print version and exit. -h, --help : Print this help and exit. Scrolling --scroll=[] : Scroll horizontally (optionally: delay ms (60)). --delta-move= : delta x and delta y when scrolling (default:1:0) For Animations, Scrolling, or Video These options influence how long/often and what is shown. --loops= : Number of runs through a full cycle. -1 means 'forever'. If not set, videos loop once, animated images forever unless there is more than one file to show. --frames=: Only show first num frames (if looping, loop only these) -t : Stop after this time, independent of --loops or --frames ``` ### Examples ```bash timg some-image.jpg # display a static image timg -g50x50 some-image.jpg # display image fitting in box of 50x50 pixel # Multiple images timg *.jpg # display all *.jpg images timg --title *.jpg # .. show name in title (short option -F) timg --title="%b (%wx%h)" *.jpg # show short filename and image size as title timg --grid=3x2 *.jpg # arrange in 3 columns, 2 rows in terminal timg --fit-width --grid=3 *.jpg # maximize use of column width (short: -W) timg --grid=3 -t5 *.gif # Load gifs one by one in grid. Play each for 5sec. # Putting it all together; making an alias to list images; let's call it ils = 'image ls' # This prints images two per row with a filename title. Only showing one frame # so for animated gifs only the first frame is shown statically. # With hi-res iTerm or Kitty terminals, consider more columns, e.g --grid=4x1 # Put this line in your ~/.bashrc alias ils='timg --grid=2x1 --upscale=i --center --title --frames=1 ' # ... using this alias on images outputs a useful column view ils *.jpg *.gif # Read the list of images to load from a file. One filename per line. locate "*.jpg" > /tmp/allimg.txt ; timg -f /tmp/allimg.txt # Show a PDF document, use full width of terminal, trim away empty border timg -W --auto-crop some-document.pdf timg --frames=1 some-document.pdf # Show a PDF, but only first page # Reading images from a pipe. The filename '-' means 'read from stdin. # In this example generating a QR code and have timg display it: qrencode -s1 -m2 "http://timg.sh/" -o- | timg - # Open an image from a URL. URLs are internally actually handled by the # video subsystem, so it is treated as a single-frame 'film', nevertheless, # many image-URLs just work. But some image-specific features, such as trimming # or scrolling, won't work. timg --center https://i.kym-cdn.com/photos/images/newsfeed/000/406/282/2b8.jpg # Sometimes, it is necessary to manually crop a few pixels from an # uneven border before the auto-crop finds uniform color all-around to remove. # For example with --auto-crop=7 we'd remove first seven pixels around an image, # then do the regular auto-cropping. # # The following example loads an image from a URL; --auto-crop does not work with # that, so we have to get the content manually, e.g. with wget. Piping to # stdin works; in the following example the stdin input is designated with the # special filename '-'. # # For the following image, we need to remove 3 pixels all around before # auto-crop can take over removing the remaining whitespace successfully: wget -qO- https://imgs.xkcd.com/comics/a_better_idea.png | timg --auto-crop=3 - timg multi-resolution.ico # See all the bitmaps in multi-resolution icons-file timg --frames=1 multi-resolution.ico # See only the first bitmap in that file timg some-video.mp4 # Watch a video. # Play content of webcam (This assumes video4linux2, but whatever input devices # are supported on your system with libavdevice-dev) timg /dev/video0 # If you read a video from a pipe, it is necessary to skip attempting the # image decode first as this will consume bytes from the pipe. Use -V option. youtube-dl -q -o- -f'[height<480]' 'https://youtu.be/dQw4w9WgXcQ' | timg -V - # Show animated gif, possibly limited by timeout, loops or frame-count timg some-animated.gif # show an animated gif forever (stop with Ctrl-C) timg -t5 some-animated.gif # show animated gif for 5 seconds timg --loops=3 some-animated.gif # Loop animated gif 3 times timg --frames=3 --loops=1 some-animated.gif # Show only first three frames timg --frames=1 some-animated.gif # Show only first frame. Static image. # Scroll timg --scroll some-image.jpg # scroll a static image as banner (stop with Ctrl-C) timg --scroll=100 some-image.jpg # scroll with 100ms delay # Create a text with the ImageMagick 'convert' tool and send to timg to scroll convert -size 1000x60 xc:none -fill red -gravity center -pointsize 42 \ -draw 'text 0,0 "Watchen the blinkenlights..."' -trim png:- \ | timg --scroll=20 - # Scroll direction. Horizontally, vertically; how about diagonally ? timg --scroll --delta-move=1:0 some-image.jpg # scroll with dx=1 and dy=0, so horizontally. timg --scroll --delta-move=-1:0 some-image.jpg # scroll horizontally in reverse direction. timg --scroll --delta-move=0:2 some-image.jpg # vertical, two pixels per step. timg --scroll --delta-move=1:1 some-image.jpg # diagonal, dx=1, dy=1 # Background color for transparent images (SVG-compatible strings are supported) # and generally useful if you have a transparent PNG that is otherwise hard # to see on your terminal background. timg -b auto some-transparent-image.png # use terminal background if possible timg -b none some-transparent-image.png # Don't use blending timg -b lightgreen some-transparent-image.png timg -b 'rgb(0, 255, 0)' some-transparent-image.png timg -b '#0000ff' some-transparent-image.png # Checkerboard/Photoshop-like background on transparent images timg -b lightgray -B darkgray some-transparent-image.png # .. with adjustable size. timg -b lightgray -B darkgray --pattern-size=4 some-transparent-image.png ``` ##### Partially transparent icon on champagne-colored terminal emulator -b auto | -b lightgreen | -b lightgreen -B yellow | -b none | ---------|---------------|-------------------------|----------| ![](img/alpha-bauto.png) | ![](img/alpha-blightgreen.png) | ![](img/alpha-blightgreen-Byellow.png) | ![](img/alpha-bnone.png) --pattern-size=1 | --pattern-size=4 | ---------------------------------------|--------------------------------------| ![](img/alpha-blightgreen-Byellow.png) | ![](img/alpha-blightgreen-Byellow-4.png) | #### Include in file browsers There are many terminal based file-browsers. Adding `timg` to their configuration is usually straight forward. ``` # Another use: can run use this in a fzf preview window: echo some-image.jpg | fzf --preview='timg -E --frames=1 --loops=1 -g $(( $COLUMNS / 2 - 4 ))x$(( $FZF_PREVIEW_LINES * 2 )) {}' # Use in vifm. ~/.config/vifm/vifmrc filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx, \*.as[fx] \ {View in timg} \ timg --title --center --clear %f, filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm \ {View in timg} \ timg --title --center --clear %f; read -n1 -s -r -p "Press any key to return", ``` #### Other fun things ```bash # Also, you could store the output and cat later to your terminal... timg -g80x40 some-image.jpg > /tmp/imageout.txt cat /tmp/imageout.txt # Of course, you can redirect the output to somewhere else. I am not suggesting # that you rickroll some terminal by redirecting timg's output to a /dev/pts/* # you have access to, but you certainly could... # Of course, you can go really crazy by storing a cycle of an animation. Use xz # for compression as it seems to deal with this kind of stuff really well: timg -g60x30 --loops=10 nyan.gif | xz > /tmp/nyan.term.xz # ..now, replay the generated ANSI codes on the terminal. Since it would # rush through as fast as possible, we have to use a trick to wait between # frames: Each frame has a 'move cursor up' escape sequence that contains # an upper-case 'A'. We can latch on that to generate a delay between frames: xzcat /tmp/nyan.term.xz | gawk '/\[.*A/ { system("sleep 0.1"); } { print $0 }' # You can wrap all that in a loop to get an infinite repeat. while : ; do xzcat... ; done # (If you Ctrl-C that loop, you might need to use 'reset' for terminal sanity) ``` ### Terminal considerations This section contains some details that you only might need to ever look at if the output is not as expected. #### Half block and quarter block rendering The half block pixelation (`-p half`) uses the the unicode character [▄](U+2584 - 'Lower Half Block') _or_ [▀](U+2580 - 'Upper Half Block') (depending on the [`TIMG_USE_UPPER_BLOCK`](#half-block-choice-of-rendering-block) environment variable). If the top and bottom color is the same, a simple space with background color is used. The quarter block pixelation (`-p quarter`) uses eight different blocks. With both of these pixelations, choosing the foreground color and background 24-bit color, `timg` can simulate 'pixels'. With the half-block pixelation, this can assign the correct color to the two 'pixels' available in one character cell, in the quarter pixelation, four 'pixels' have to share two colors, so the color accuracy is slighlty worse but it allows for higher spatial resolution. The `-p` command line flag allows to choose between `-p half`, `-p quarter`, also possible to just shorten to `-ph` and `-pq`. Default is `-pq` (see [above](#pixelation) how this looks like). Terminals that don't support Unicode or 24 bit color will probably not show a very pleasent output. For terminals that only do 8 bit color, use the `--color8` command line option. #### Some terminals support direct image output The [Kitty], [iTerm2], and [wezterm] terminals have a special feature that allows for directly displaying high-resolution pictures. If `timg` is running in such a terminal, it will automatically use that mode. (You can choose Kitty mode explicitly with `-pk`, iTerm and wezterm mode with `-pi`). All the features with arranging images (center, grid, adding titles) or transparency settings behave exactly the same. Note, if watching videos remotely with this is too slow (due to high bandwidth requirements or simply because your terminal has to do more work), try setting the environment variable `TIMG_ALLOW_FRAME_SKIP=1` to allow timg leaving out frames to stay on track (see `man timg`, environment variable section). #### Half block: Choice of rendering block By default, `timg` uses the 'lower half block' to show the pixels in `-p half` mode. Depending on the font the terminal is using, using the upper block might look better, so it is possible to change the default with an environment variable. Play around with this value if the output looks poor on your terminal. I found that on my system there is no difference for [`konsole`][konsole] or `xterm` but the [`cool-retro-term`][cool-retro-term] looks better with the lower block, this is why it is the default. In some terminals, such as [alacritty] (and only with certain font sizes), there seems to be the opposite working better. To change, set this environment variable: ``` export TIMG_USE_UPPER_BLOCK=1 # change default to use upper block. ``` (this only will work fully with `-p half`. In `-p quarter` mode, there are additional blocks that can't be worked around) ##### What a problematic choice of block looks like The image generally looks a bit 'glitchy' if the terminal leaves little space between blocks, so that the wrong background color shows on a single line between pixels. This is likely not intended by the terminal emulator and possibly happening on rounding issues of font height or similar. Anyway, we can work around it (fully in `-p half`, partially in `-p quarter` mode). In the following illustration you see how that looks like. If you see that, change the `TIMG_USE_UPPER_BLOCK` environment variable. Glitchy. Change TIMG_USE_UPPER_BLOCK| Looks good ------------------------------------|-------------------------------| ![](img/needs-block-change.png) | ![](img/block-ok.png)| #### Other artifacts Some terminals leave one pixel of horizontal space between characters that result in fine vertical lines in the image. That can't be worked around, send a bug or better pull request to your terminal emulator. #### Wrong font aspect ratio Usually, timg attempts to determine the font aspect ratio and apply some correction if it is off from the nominal 1:2. But if you notice that the image displayed is not quite the right aspect ratio because of the terminals font used, you can set an environment variable `TIMG_FONT_WIDTH_CORRECT` with a factor to make it look correctly. Increasing the visual width by 10% would be setting the value to 1.1 for instance. ``` export TIMG_FONT_WIDTH_CORRECT=1.1 timg myimage.jpg ``` This is an environment variable, so that you can set it once to best fit your terminal emulator of choice and don't have to worry about later. ##### Example Terminal font too narrow | Correct. Here with `TIMG_FONT_WIDTH_CORRECT=1.375` ---------------------------|-------------------------------| ![](img/aspect-wrong.png) | ![](img/aspect-right.png)| #### Tested terminal emulators (Needs update; these comparisons are from 2016 when I tested this last with timg, so newer terminals are probably even better). Tested terminals: `konsole` >= 2.14.1, `gnome-terminal` > 3.6.2 look good, recent xterms also seem to work (albeit with less color richness). Like gnome-terminal, libvte based terminals in general should work, such as Xfte or termite. Also QTerminal is confirmed working. Linux console seems to be limited in colors and does not show the block character - if you know how to enable the unicode character or full color there, please let me know. For Mac users, at least the combination of macOS 11.2 and iTerm2 3.4.3 works. ### Install pre-built package #### Debian-based systems ```bash sudo apt install timg ``` (currently in Debian testing) #### NixOS or Nix package manager ```bash nix-env -iA nixpkgs.timg ``` #### macOS ```bash brew install timg ``` #### Linux distributions that support snap packages If you have enabled support for snap packages in your Linux distribution, you can install `timg` with ``` sudo snap install timg ``` ### Build from source #### Get dependencies on Debian/Ubuntu ```bash sudo apt install cmake git g++ pkg-config sudo apt install libgraphicsmagick++-dev libturbojpeg-dev libexif-dev libswscale-dev # needed libs # If you want to include video decoding, also install these additional libraries sudo apt install libavcodec-dev libavformat-dev sudo apt install libavdevice-dev # If you want to read from video devices such as v4l2 sudo apt install libopenslide-dev # If you want to add OpenSlide images support sudo apt install pandoc # If you want to recreate the man page ``` #### Get dependencies on NixOS or Nix package manager The dependencies are set-up in the shell.nix, so you're ready to go opening a nix shell ```bash nix-shell ``` #### Get dependencies on macOS ```bash # Homebrew needs to be available to install required dependencies brew install cmake git GraphicsMagick webp jpeg-turbo libexif # needed libs # Work around glitch in pkg-config and jpeg-turbo. brew unlink jpeg && brew link --force jpeg-turbo # If you want to include video decoding, install these additional libraries brew install ffmpeg # If you want to add OpenSlide images support brew install openslide brew install pandoc # If you want to recreate the man page ``` #### Get repo and compile timg In the script below you see that the build system allows for some compile-time choices: * **`WITH_VIDEO_DECODING`** allow for video decoding. Requires ffmpeg-related libraries. You typically want this **ON** (default) * **`WITH_VIDEO_DEVICE`** this allows for accessing connected video devices, e.g. you can watch your webcam input (requires `WITH_VIDEO_DECODING`). * **`WITH_GRAPHICSMAGICK`** This is the main image loading library so you typically want this **ON** (default). * **`WITH_TURBOJPEG`** If enabled, uses this for faster jpeg file loading. You typically want this **ON** (default). * **`WITH_OPENSLIDE_SUPPORT`** Openslide is an image format used in scientific applications. Default off, switch ON if needed. * **`WITH_STB_IMAGE`** Compile the simpler STB image library directly into the timg binary in cases where Graphicsmagick is not suitable for dependency pruning reasons; output can be slower and of less quality. You typically want this **OFF** (default) if you can use Graphicsmagick. You can choose these options by providing `-D