
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
vimg: A CLI image viewer. #########################
Author: Johannes Hansen
If you are like me, you spend a lot of time in command line environments. One of the few things that are hard to deal with in such an environment is images.
This little tool is meant to allow for quick viewing of image files in the command line.
The image is rendered using a combination of background color, foreground color and unicode character for each character cell to optimally represent the original pixels. The challenge is the limited color palette of 256 colors.
In the simplest case, each character cell represents one pixel. However, the resolution can be increased by printing unicode characters that better capture the structure of the image. Alternatively, the color accuracy can be improved by mixing two available colors in foreground and background, thus losing the gained resolution.
The default mode attempts to optimize the rendering by optimizing resolution in areas of high detail, and optimizing color accuracy in areas of low detail.
.. code-block:: bash
$ pip install vimg
A terminal that supports 256 colors.
The script is based on curses
and opencv
for Python.
.. code-block:: bash
$ vimg path/to/image
Once in the GUI, you can change between different viewing modes:
+--------------------------+---------+-------------------------------------------------------------+
| Key shortcut | Mode | Description |
+==========================+=========+=============================================================+
| c
| color | (default) display optimal representation of image |
+--------------------------+---------+-------------------------------------------------------------+
| f
| fast | display image in fast mode (reduced resolution) |
+--------------------------+---------+-------------------------------------------------------------+
| a
| ascii | display a black-and-white representation of the image |
+--------------------------+---------+-------------------------------------------------------------+
| e
| edge | (experimental) edge detection based rendering |
+--------------------------+---------+-------------------------------------------------------------+
| +
/-
| -- | zoom in/out (by 30%) |
+--------------------------+---------+-------------------------------------------------------------+
| | h
j
k
l
| -- | move view (by 10%) |
| | or arrow keys | | |
+--------------------------+---------+-------------------------------------------------------------+
| 0
| -- | reset zoom |
+--------------------------+---------+-------------------------------------------------------------+
| r
| -- | refresh the screen |
+--------------------------+---------+-------------------------------------------------------------+
| q
| -- | quit |
+--------------------------+---------+-------------------------------------------------------------+
The results will be better if you use a font that correctly displays unicode block element characters with the full line height, such as DejaVu Sans.
The script currently only supports image files that are natively supported by OpenCV (.jpg
,
.png
, .bmp
).
Future plans include:
.gif
opencv
dependency optionalFAQs
An image viewer for the command line
We found that vimg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.