https://patbeagan.dev/projects/consolevideo
ConsoleVision
is a library that will take a bitmap and convert it to a ANSI
With this tool, you'll be able to display images without leaving your terminal. This can be useful when you are just sshing into another machine and don't have GUI access.
To make this more convenient, there is an option to run the tool as a server instead, so the only thing that you need installed is curl
As a Library
The library jar file includes an implementation of ANSI for the JVM. It has some similar content to Jansi (which I was unaware of at the time), but it includes extensions that make it more useful for image processing.
As an App
The app supports a variety of command line flags which will allow for:
- colorspace reduction
- color normalization
- image resizing
- compatibility mode (for old terminals that only support 256 colors)
Normalized Colors | Default | Custom palette | Reduced colorspace |
---|---|---|---|
As a Server
Running the tool as a server will allow you to use a limited feature set of the command line tool, in a more convenient way.
- To upload a photo, POST to the
/upload
endpoint. You'll receive an image hash. - To retrieve a photo, GET to the
/im/{id}
endpoint, using an image hash. - To retrieve the last photo, GET to the
/last
endpoint - To retrieve a random photo, GET to the
/random
endpoint
Retreival by image id | Uploading an image | Retrieval of random, previously uploaded image | Retrieval of last uploaded image |
---|---|---|---|
You can add the following to your ~/.bashrc or ~/.zshrc file to add an upload command. Replace localhost with the server you are accessing.
cvupload () {
curl -X POST -F 'image=@'"${'$'}1" localhost:3000/upload
}
cvimage () {
curl localhost:3000/im/"${'$'}1"
}
I have a server where this is deployed as well, if you just want to test it out.
curl 3.221.34.94/im/eefbb5b84ef2d8824f3fcaf64c54a63a
Initial functionality that allowed for playing videos has been taken out. The video player that was being used, humble, was not able to be packaged into a shadow jar.
Done
- Convert to compose
In progress
- Convert all functionality to multiplatform
- Verify terminal compatibility
- Only rerender screen diff
- scanlines,
- individual pixels
- reduce cpu strain
- limit FPS
- Text support
- Demos
- Pokedex
- Mandelbrot zoom
Todo
- More filters
- Display as quad blocks, similar to chafa
- Standardize screen size
- Handle click events
- Handle keyboard input
- Widget library
- Publish to package managers
- Gif support
- Pass compression style in as an argument