The TermView package renders images and videos within the terminal.
Importing Termview
Just like any package, you need to require termview to use it.
const termview = require ( 'termview' );
// Now that termview is imported, you can use "Image, Video, and Gif" functions copy
Image
The Image function 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) copy
Video
The Video function 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' ) copy
The Video also has two sub functions. Video.preload and Video.render
Video.preload
The Video.preload function will load the frame data and return an object like the one below.
{
frames : [ /* Array of escape codes */ ],
width : Number,
height : Number,
fps : Number,
} copy
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
GIF
The Gif function 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 ) copy