termview
v1.0.0
Published
Termview is a package that allows you to render images, videos, GIFS, in the terminal.
Maintainers
Readme
TermView
The TermView package renders images and videos within the terminal.
Installing
npm install termviewUsing
Importing Termview
Just like any package, you need to
requiretermview to use it.const termview = require('termview'); // Now that termview is imported, you can use "Image, Video, and Gif" functionsImage
The
Imagefunction can be passed up to four parameters.- The path/url to the image to render
- The optional width to render
- The optional height to render
var render = await termview.Image('./myimage.png') console.log(render)Video
The
Videofunction can be passed up to four parameters.- The path/url to the video to render
- The optional FPS to render
- The optional width to render
- The optional height to render
await termview.Video('./myvideo.mp4')The
Videoalso has two sub functions.Video.preloadandVideo.renderVideo.preload
The
Video.preloadfunction will load the frame data and return an object like the one below.{ frames: [/* Array of escape codes */], width: Number, height: Number, fps: Number, }When calling this function, you can pass up to 3 parameters:
- The path/url to the video to load
- The optional width to load
- The optional height to load
/* Load the video */ var video = await termview.Video.preload('./myvideo.mp4') /* render the video */ await termview.Video.render(video);Video.render
The
Video.renderfunction will render previusly loaded frame data.When calling this function, pass an object in the format of:
{ frames: [/* Array of escape codes */], width: Number, height: Number, fps: Number, }Example:
/* Load the video */ var video = await termview.Video.preload('./myvideo.mp4') /* { frames: [...], width: ..., height: ..., fps: ..., } */ /* render the video */ await termview.Video.render(video);
GIF
The
Giffunction can be passed up to four parameters.- The path/url to the GIF to render
- The optional number of iterations to loop (default
10) - The optional width to render
- The optional height to render
await termview.Gif('./mygif.gif', 100)
