Compatibility with cli-table?
donmccurdy opened this issue · 2 comments
Doing a quick test to see if I can use this with https://github.com/Automattic/cli-table ...
const terminalImage = require('terminal-image');
const Table = require('cli-table');
(async () => {
const img = await terminalImage.file(process.argv[2], {width: 50, height: 50});
const table = new Table({head: ['img', 'caption']});
table.push([img, 'description #1'], [img, 'description #2']);
console.log(table.toString());
})();
It works nicely in macOS native terminal:
But in iTerm 2 I'm getting a screen full of lines, like the table thinks the output is (much) larger than it is. Customizing row widths in cli-table doesn't seem to help. Any idea if this is something I could reasonably expect to work, or just incompatible with whatever special image rendering iTerm 2 has? Maybe related to #29? Thanks!
iTerm uses a completely different method to render images, which gives us less control over the output. I'm open to adding an option to disable the special iTerm rendering though. That would solve your problem. A good PR would be welcome.
Thanks — Do you know what you'd want the option to be called? Looking at #29 and the comment "The hard part might be to decide, whether to use SIXEL on a certain terminal. Maybe a switch would do in the beginning...", perhaps a format
option that's future-proof against that addition?
terminalImage.file('image.png', {
format: "AUTO" | "COMPAT" | "SIXEL"
});