wookayin / python-imgcat Goto Github PK
View Code? Open in Web Editor NEW🖼 imgcat in Python (for iTerm2)
License: MIT License
🖼 imgcat in Python (for iTerm2)
License: MIT License
Great tool.
It would be v. useful to have the option to do this:
ls | xargs imgcat
The main use case (at least for me) is when you want a quick visual summary from a large directory of images. E.g.
ls | shuf | head -n 10 | xargs imgcat
This works with the original imgcat
, but with python-imgcat
, I get the following:
error: when reading from stdin, arg should not be given
Thanks!
wow that looks dope, would it be possible to support kitty (a cross platform python terminal) as well ? it seems to have its own format too https://sw.kovidgoyal.net/kitty/graphics-protocol.html (the link provides a python function to use the protocol).
Another implementation reference could be:
https://pypi.org/project/pixcat/#description
Using imagcat as a matplotlib module backend now (since v3.6) throws the warning:
MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later.
Here is the deprecation notice.
Hi,
I would like to display images written as PDF files.
Would this be possible?
Awesome software anyway,
Thanks
img = np.random.randint(0, 255, [512,512], np.uint8)
imgcat(img) # the output image will auto resized to (372, 372)
If I try to run this excellent tool inside a command such as this (which I do heavily):
find images/ -iname "*dog*.jpg" | xargs -n 1 imgcat
you get:
error: when reading from stdin, arg should not be given
What should happen in this usage model is that imgcat
should run one arg at a time on each file that matches the glob pattern *dog*.jpg
.
Is there any chance this can be fixed? Once it is, the tool is perfect :)
Not sure how to debug this :( Instead of the image, imgcat
displays only empty lines.
macOS version: 13.1 (22C65)
iTerm2 version: 3.4.19
tmux version: 3.3a
python version: 3.10.3
In an IPython (or Jupyter) console, imgcat errors and fails to load images, even when using kitty and explicitly setting the TERM environment variable to xterm-kitty
. I'm not sure if this a bug report or feature request (or even a problem with Jupyter!), especially since the IPython/Jupyter console explicitly changes the TERM environment variable. I think this would be a useful feature/fix in any case, as an IPython provides many benefits over a python REPL.
Steps to reproduce:
-Start an IPython or Jupyter console using kitty (problem occurs with both python 3.6 and 3.8 for me)
-Explicitly change TERM value with %set_env TERM=xterm-kitty
[or don't, doesn't make a difference in the outcome :)]
-Set matplotlib backend to imgcat, and plot something
-imgcat throws 'OutStream' object has no attribute 'buffer'
The module is working perfectly for me in kitty in a python REPL. Thanks for this great project!
If not given height/width, the image will not display.
I viewer the code, perhaps the height
and width
para has not been working.
networkx
(b.) matplotlib.pyplot
(c.) imgcat
to work together... (ab) work together well verified, (bc) work together per the imagecat documentation, (c) alone work well verified... but how to get (abc) to work 😅 ?# Works Well
from imgcat import imgcat
imgcat(open("Figure_1.png"))
I was thinking maybe there's some way to plt.savefig()
to some variable then render that via imgcat()
but that doesn't seeem to work either...
import matplotlib
matplotlib.use("module://imgcat")
import networkx as nx
import matplotlib.pyplot as plt
# from imgcat import imgcat
edges = [(1,2),(2,3),(2,4)]
nxgraph = nx.Graph()
nxgraph.add_edges_from(edges)
nx.draw_networkx(nxgraph)
# fig = nx.draw_networkx(nxgraph)
plt.show()
# plt.savefig()
# imgcat(fig)
Traceback (most recent call last):
File "<DIR>\nx-pydot-graphviz-imgcat.py", line 15, in <module>
nx.draw_networkx(nxgraph)
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\networkx\drawing\nx_pylab.py", line 303, in draw_networkx
draw_networkx_nodes(G, pos, **node_kwds)
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\networkx\drawing\nx_pylab.py", line 416, in draw_networkx_nodes
ax = plt.gca()
^^^^^^^^^
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\matplotlib\pyplot.py", line 2309, in gca
return gcf().gca()
^^^^^
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\matplotlib\pyplot.py", line 906, in gcf
return figure()
^^^^^^^^
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\matplotlib\_api\deprecation.py", line 454, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\matplotlib\pyplot.py", line 861, in figure
draw_if_interactive()
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\matplotlib\pyplot.py", line 397, in draw_if_interactive
return _get_backend_mod().draw_if_interactive(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ProgramFiles\Python\Python311\Lib\site-packages\matplotlib\backend_bases.py", line 3583, in draw_if_interactive
manager_class = cls.FigureCanvas.manager_class
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'manager_class'
I got the following error.
It seems that matplotlib.use(module://imgcat)
is not working.
Below is an example of an error made by a one-liner
I get the same error with matplotlib.use(module://imgcat)
$ MPLBACKEND="module://imgcat" python -c 'import imgcat, matplotlib.pyplot as plt; plt.show()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/hiroshi.toyama/.pyenv/versions/3.10.8/lib/python3.10/site-packages/matplotlib/pyplot.py", line 526, in show
_warn_if_gui_out_of_main_thread()
File "/Users/hiroshi.toyama/.pyenv/versions/3.10.8/lib/python3.10/site-packages/matplotlib/pyplot.py", line 441, in _warn_if_gui_out_of_main_thread
canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
File "/Users/hiroshi.toyama/.pyenv/versions/3.10.8/lib/python3.10/site-packages/matplotlib/pyplot.py", line 280, in _get_backend_mod
switch_backend(rcParams._get("backend")) # type: ignore[attr-defined]
File "/Users/hiroshi.toyama/.pyenv/versions/3.10.8/lib/python3.10/site-packages/matplotlib/pyplot.py", line 343, in switch_backend
canvas_class = module.FigureCanvas
AttributeError: module 'imgcat' has no attribute 'FigureCanvas'
Hello @wookayin i want to Run and install imgcat on server (linux based) to directly view images on server rather view it on Mac. I use MobaXterm to connect to server, while, my basic question is that there is any way i can install imgcat on my server to view images on server, rather, i install another software on my laptop and then run imgcat on the laptop to see images? I hope you understand my issue.
Add a Sixel backend for imgcat. This is a widely adopted protocol for displaying graphics. One may use libsixel (and its python binding) or direct implementation (akin to lsix) if we value portability more.
Terminal requirements and compatibility list:
Due to pytest-runner being in a deprecated state (as seen in references [1] [2]), it is recommended that the author clean up the dependency of imgcat on pytest-runner. Conflicts caused by this dependency can lead to incorrect installation issues during pip install.
[1] https://github.com/pytest-dev/pytest-runner/
[2] https://pypi.org/project/pytest-runner/
Deprecation Notice
pytest-runner depends on deprecated features of setuptools and relies on features that break security mechanisms in pip. For example ‘setup_requires’ and ‘tests_require’ bypass pip --require-hashes. See also pypa/setuptools#1684.It is recommended that you:
Remove 'pytest-runner' from your setup_requires, preferably removing the setup_requires option.
Remove 'pytest' and any other testing requirements from tests_require, preferably removing the tests_requires option.
Select a tool to bootstrap and then run tests such as tox.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.