Code Monkey home page Code Monkey logo

imgcat's Introduction

imgcat

Build Status

It's like cat but for images.

running `imgcat cat.jpg`

Install

On macOS:

brew install eddieantonio/eddieantonio/imgcat

Important: See below if you're using iTerm2 3.0 with shell integration installed.

For other platforms, see Build.

Usage

imgcat some_image.jpg

See the manpage for more invocations.

Note on iTerm2's shell integration

If you install iTerm2's shell integration, chances are you also installed its additional scripts, including one called imgcat. iTerm's imgcat overrides this program by default. To see if this is happening to you, use which to determine where your shell is finding imgcat:

which imgcat

If it says imgcat: aliased to /Users/yourusername/.iterm2/imgcat, then you must edit your shell startup file and add unalias imgcat after the line that sources iTerm2's script. For example:

test -e ${HOME}/.iterm2_shell_integration.zsh && source ${HOME}/.iterm2_shell_integration.zsh
unalias imgcat

Build

Clone

You must use git clone --recurse-submodules to clone this repository with its dependency, CImg:

git clone --recurse-submodules https://github.com/eddieantonio/imgcat.git

Requirements

To build from source, you need the following:

  • GNU make
  • pkg-config
  • ncurses with header files

On Debian/Ubuntu/Mint/etc. you can get these packages with this command:

sudo apt-get install build-essential pkg-config libncurses5-dev

Recommended dependencies

These dependencies are not necessary, but if pkg-config manages to find a compatible version on the system, imgcat will link to it!

  • libpng (any 1.x version supported by CImg)
  • libjpeg (any version supported by CImg)

On Debian/Ubuntu/Mint/etc. you can get these packages with this command:

sudo apt-get install libpng-dev libjpeg-dev

Then:

./configure
make

Install

To install to /usr/local:

make install

To change the default prefix, simply provide PREFIX=... to make install:

make install PREFIX=/opt

Acknowledgements

License

Copyright © 2014–2023 Eddie Antonio Santos. Distributed under the terms of the ISC license.

imgcat's People

Contributors

dotiful avatar eddieantonio avatar efferifick avatar jbudone avatar julienc91 avatar kennbr34 avatar mdesantis avatar snobu avatar sotpapathe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgcat's Issues

Add pipe support

Being able to pipe in an image, rather than having to read from a saved file, would be a very useful feature addition to an already very useful tool.

One use case that I've run into is trying reading thumbnail data from large file types (like Photoshop files). Using exiftool, it's easy to extract the thumbnail data from a Photoshop file, but I find myself having to save it to a temporary file in order to be able to view it.

Currently, this process looks something like this:

exiftool -b -PhotoshopThumbnail example.psd > temp.jpg
imgcat temp.jpg
rm temp.jpg

But having something like this would be much more useful:

exiftool -b -PhotoshopThumbnail example.psd | imgcat

During homebrew installation: "<<-EOS.undent is disabled"

During the initial install of imgcat (via HomeBrew), I received the following error message:

==> Installing imgcat from eddieantonio/eddieantonio
==> Downloading https://github.com/eddieantonio/imgcat/archive/v2.1.0.tar.gz
==> Downloading from https://codeload.github.com/eddieantonio/imgcat/tar.gz/v2.1
######################################################################## 100.0%
==> autoconf
==> ./configure
==> make install PREFIX=/usr/local/Cellar/imgcat/2.1.0
Error: Calling <<-EOS.undent is disabled!
Use <<~EOS instead.
/usr/local/Homebrew/Library/Taps/eddieantonio/homebrew-eddieantonio/imgcat.rb:25:in `caveats'
Please report this to the eddieantonio/eddieantonio tap!
Or, even better, submit a PR to fix it!

is this based on hiptext?

hiptext does the same as this tool but it also supports videos, so what is the difference or why should we pick this one instead?

Not working with screen

Hello, imgcat is working for me on Catalina (not with jpg as someone else reported), but not over screen. When I try to use over screen, i just get the base64'd string.

Any idea what might be wrong? Thank you.

A flaw of memory leak

this bug was found with afl.

proof:

=================================================================
==26325==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7499 byte(s) in 1 object(s) allocated from:
#0 0x7f7716c54cef in operator new[](unsigned long) ../../../../libsanitizer/asan/asan_new_delete.cc:107
#1 0x54f41b in cimg_library::CImg::CImg(unsigned int, unsigned int, unsigned int, unsigned int) CImg/CImg.h:11793
#2 0x54f41b in cimg_library::CImg::_load_jpeg(_IO_FILE*, char const*) CImg/CImg.h:51847
#3 0x58272f in cimg_library::CImg::load_jpeg(char const*) CImg/CImg.h:51771
#4 0x58272f in cimg_library::CImg::load(char const*) CImg/CImg.h:51419
#5 0x41d800 in cimg_library::CImg::assign(char const*) CImg/CImg.h:12578
#6 0x41d800 in load_image src/load_image.cc:49
#7 0x40f7e3 in print_iterate src/print_image.c:95
#8 0x40f7e3 in print_image src/print_image.c:77

SUMMARY: AddressSanitizer: 7499 byte(s) leaked in 1 allocation(s).

[NAME OF AFFECTED PRODUCT(S) AND VERSION(S)]
CImg v2.9.3

[PROBLEM TYPE]
memory leak, cause program crash.

[DESCRIPTION]
The problem arises when using the CImg::load_jpeg function

jpeg sample file:

memory_leak_sample

trying to compile on manjoro

I'm having this issue:
++ src/imgcat.o src/rgbtree.o src/print_image.o src/load_image.o -ljpeg -lpng -ltermcap -lm -lpthread -o imgcat
/usr/bin/ld: cannot find -ltermcap
collect2: error: ld returned 1 exit status
make: *** [Makefile:51: imgcat] Error 1

imgcat not working!

I'm using imgcat on my Mac mini. However, it's not working on my iterm2 after download. It only print out the symbol and numbers but the figure.
image

Error installing with MacOS 14.0 (Sonoma)

When attempting to run brew install eddieantonio/eddieantonio/imgcat on MacOS 14.0 (Sonoma), it fails with the following error:

Last 15 lines from /Users/mikelkew/Library/Logs/Homebrew/imgcat/01.configure:
__OSX_AVAILABLE(14.0) __IOS_AVAILABLE(17.0) __WATCHOS_AVAILABLE(10.0)
                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/term.h:759:17: error: expected parameter declarator
__OSX_AVAILABLE(14.0) __IOS_AVAILABLE(17.0) __WATCHOS_AVAILABLE(10.0)
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/term.h:759:17: error: expected ')'
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/term.h:759:16: note: to match this '('
__OSX_AVAILABLE(14.0) __IOS_AVAILABLE(17.0) __WATCHOS_AVAILABLE(10.0)
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/term.h:759:23: error: expected function body after function declarator
__OSX_AVAILABLE(14.0) __IOS_AVAILABLE(17.0) __WATCHOS_AVAILABLE(10.0)
                      ^
6 errors generated.
no
./configure: error: failed to find required header: term.h

Have you come across this before, or happen to have any ideas for how to resolve it?

Brew update raises deprecation warnings

Hello!

As the title suggests, when running brew update this morning
I received the following 🌵 warnings 🌵 :

➜  ~ brew update
Warning: Calling Formula.sha1 is deprecated!
Use Formula.sha256 instead.
/usr/local/Library/Taps/eddieantonio/homebrew-eddieantonio/imgcat.rb:4:in `<class:Imgcat>'
Please report this to the eddieantonio/eddieantonio tap!

Warning: Calling SoftwareSpec#sha1 is deprecated!
Use SoftwareSpec#sha256 instead.
/usr/local/Library/Taps/eddieantonio/homebrew-eddieantonio/imgcat.rb:4:in `<class:Imgcat>'
Please report this to the eddieantonio/eddieantonio tap!

Warning: Calling Resource#sha1 is deprecated!
Use Resource#sha256 instead.
/usr/local/Library/Taps/eddieantonio/homebrew-eddieantonio/imgcat.rb:4:in `<class:Imgcat>'
Please report this to the eddieantonio/eddieantonio tap!

fail on grayscale image

imgcat: src/load_image.cc:48: bool load_image(const char*, Image*, LoadOpts*): Assertion `(img.spectrum() == 3) || (img.spectrum() == 4)' failed.

Image is too blurry?

Hi,

Basically, image is not in useful condition when i print "imgcat image.png". I've tried with both jpeg and png.

I'm using MacOS 10.14.5
followed up install instructions:
$brew tap eddieantonio/eddieantonio
$brew install imgcat

[Desktop]$ imgcat --version
imgcat 2.3.0
[Desktop]$ tput colors
256
Using MacOS Terminal 2.9.5 (421.2)

Screen Shot 2019-06-08 at 3 52 17 AM

--width or -w arguments ignored in 2.1.0

$> which imgcat
/usr/local/bin/imgcat

$> imgcat -v
imgcat 2.1.0

$> echo $TERM
xterm-256color

iterm2: build 3.1.5

For all of these permutations, the image shows up in full-screen:

imgcat -w 10 img.jpg
imgcat --width 10 img.jpg
imgcat --width 10--no-rescale img.jpg

What am I doing wrong? How can I display a resized image?

Can't display svg images on my Mac

Not sure if it is my mac issue:

imgcat <(curl -s https://upload.wikimedia.org/wikipedia/commons/f/fa/Apple_logo_black.svg)

it shows:

image

For other types of image, png for example, it works.

CImg directory blank after git clone

I noticed when I cloned the repository using the 'git clone' the directory 'CImg' was empty, which caused problems with compilation when 'CImg.h' was needed.

Python 3 is not yet supported

hi,

I get the following error:

scons install production=true
scons: *** SCons version 2.5.1 does not run under Python version 3.5.0.
Python 3 is not yet supported.
make: *** [install] Error 1

Use L*A*B* colourspace for image quantization

This may result in perceivably more accurate colour quantization.

The nonlinear relations for L*, a*, and b* are intended to mimic the nonlinear response of the eye. Furthermore, uniform changes of components in the L*a*b* color space aim to correspond to uniform changes in perceived color, so the relative perceptual differences between any two colors in L*a*b* can be approximated by treating each color as a point in a three-dimensional space (with three components: L*, a*, b*) and taking the Euclidean distance between them. 1
—From Wikipedia

Footnotes

  1. Jain, Anil K. (1989). Fundamentals of Digital Image Processing. New Jersey, United States of America: Prentice Hall. pp. 68, 71, 73. ISBN 0-13-336165-9.

Create a Windows package

Make it easy to distribute on Windows! I literally have no idea how to do this myself, so help wanted.

Can't seem to pass width or height options with ITerm2 Shell Integrations

Wasn't sure if it was related to having my shell set to ZSH so I tried in bash, passing width options worked but renders gif images as stills and they look pixelated. I'm running Iterm in xterm-256color. But after installing shell integrations in bash I get same result so it's not shell related.

Here's output before install shell integrations, takes width param and displays pixelated but sized to width.
screen shot 2017-04-14 at 4 51 04 am

And here's after installing ITerm2 shell integrations. Rejects -w args but shows high res gif which is animated (screen shot is still) but stays default actual image width.
Also I tried with imgcat gify.gif -w 15 and gives exact same output with same error message.
screen shot 2017-04-14 at 4 51 56 am

Homebrew no formula

When installing via brew, I got the following error:
image

How can I fix this? Thanks.
Home brew version:
image

Add height option

When using this command, you’d ideally want the image to be as large as possible without going offscreen. The width parameter works quite well for landscape images, but portrait images will still be too large. Adding equivalent functionality for height would be very useful.

Linux build error: `pkg-config: not found`

$ ./configure

checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for term.h... yes
checking for sysexits.h... yes
checking to compile C++ with -std=c++11...yes
checking to link with libncurses [using tigetnum()]... yes
checking to link with libpng using pkg-config [using png_create_info_struct()]... ./configure: 172: pkg-config: not found
/usr/bin/ld: /tmp/ccKOPT4A.o: in function `main':
conftest.3135590.c:(.text+0x5): undefined reference to `png_create_info_struct'
collect2: error: ld returned 1 exit status
no
checking to link with libjpeg using pkg-config [using jpeg_set_defaults()]... ./configure: 172: pkg-config: not found
/usr/bin/ld: /tmp/ccIrQLgp.o: in function `main':
conftest.3135590.c:(.text+0x5): undefined reference to `jpeg_set_defaults'
collect2: error: ld returned 1 exit status
no
checking for pandoc... no
warning: ignoring requirement for pandoc...
creating config.mk
creating src/config.h
creating src/cimg_config.h

After executing sudo apt-get install pkg-config, everything is OK.

$ ./configure

checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for term.h... yes
checking for sysexits.h... yes
checking to compile C++ with -std=c++11...yes
checking to link with libncurses [using tigetnum()]... yes
checking to link with libpng using pkg-config [using png_create_info_struct()]... yes
checking to link with libjpeg using pkg-config [using jpeg_set_defaults()]... yes
checking for pandoc... no
warning: ignoring requirement for pandoc...
creating config.mk
creating src/config.h
creating src/cimg_config.h

Mind adding pkg-config as a build dependeny in README?

read from NULL while cat a bmp file

terminate called after throwing an instance of 'cimg_library::CImgArgumentException'
what(): cimg::fread(): Invalid reading request of 0 unsigned char from file 0x7453a0 to buffer (nil).

test.zip

1.0 Roadmap

  • Python script to generate kd-tree
  • Get 256 color mapping
  • Determine terminal color depth
  • Write printing function
  • Write rescale
  • Check if is a tty.
  • Argument parsing
    • Option: --depth (force colour depth)
    • Option --no-resize
    • Option: --width
  • Remove need for aggressive assertions
  • Install
  • Manpage
  • Package for package managers
  • Get 8 16 8 color mapping
  • More compatible static assert
  • Make pixel test.
  • Automatic testing (47454d7)
  • Cross-platform continuous integration
  • Build sticker in README, because that is of utmost importance
  • More illustrative front-page picture
  • --help and --version options
  • Make some real test cases

Build failure: doesn't detect ncurses

It seems to look for curses instead of ncurses.

[   17s] + ./configure --host=i586-suse-linux-gnu --build=i586-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking
[   17s] checking to link with libcurses [using tigetnum()]... /usr/lib/gcc/i586-suse-linux/11/../../../../i586-suse-linux/bin/ld: cannot find -lcurses
[   17s] collect2: error: ld returned 1 exit status
[   17s] no
[   17s] ncurses is required for compilation

This seems to be the solution #36
But apparently we don't use autotools/configure.ac anymore. (Why is that the case?)

Full build log: https://build.opensuse.org/build/home:jubalh/openSUSE_Tumbleweed/i586/imgcat/_log

Failed to open image

I'm getting the following error message trying to open an image

imgcat: Failed to open image: yorkshire_terrier_9.jpg

It doesn't appear to be a permission problem because I can do a hexdump on the file with hexdump Yorkshire_terrier_9.jpg. I doubt that the image is corrupted as it's part of a well known image dataset.

I've been able to correctly display images from another dataset but they were png's so I don't know if this problem is specific to jpgs.

Install: fatal error: term.h: No such file or directory

When attempting to run brew install eddieantonio/eddieantonio/imgcat on Ubuntu 22.04 I received the following:

==> Installing eddieantonio/eddieantonio/imgcat
==> ./configure
Last 15 lines from /home/user/.cache/Homebrew/Logs/imgcat/01.configure:
2023-03-14 21:36:24 +0000

./configure

checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for term.h... /tmp/conftest.949801.c:1:12: fatal error: term.h: No such file or directory
    1 |   #include <term.h>
      |            ^~~~~~~~
compilation terminated.
no
./configure: error: failed to find required header: term.h

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.