Skip to content

A kotlin program (and library) for displaying images in the terminal.

License

Notifications You must be signed in to change notification settings

patbeagan1/ConsoleVision

Repository files navigation

ConsoleVision

https://patbeagan.dev/projects/consolevideo Screenshot_2022-04-27_23-45-04

What is this project about?

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

What's included?

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)
Screen Shot 2022-02-05 at 8 43 56 AM
Normalized Colors Default Custom palette Reduced colorspace
Screen Shot 2022-02-05 at 8 51 15 AM Screen Shot 2022-02-05 at 8 50 53 AM Screen Shot 2022-02-05 at 9 03 37 AM Screen Shot 2022-02-05 at 9 02 59 AM
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
Screen Shot 2022-02-05 at 8 28 51 AM Screen Shot 2022-02-05 at 8 35 50 AM Screen Shot 2022-02-05 at 8 30 56 AM Screen Shot 2022-02-05 at 8 38 25 AM

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"
}
Screen Shot 2022-02-05 at 11 37 36 AM

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

Other things to note?

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.

Roadmap

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