xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.33k stars 1.61k forks source link

xterm-addon-image: IIP image not displayed #4942

Closed x1unix closed 7 months ago

x1unix commented 7 months ago

Hello, I'm trying to display an iip-encoded PNG image using xterm.js.

I tested the same sequence in the real iTerm2 terminal and with xterm.js. I don't know why, but the image that works in iTerm, doesn't work in xterm.js

Details

Steps to reproduce

  1. Open iTerm2 locally and run node.js to print the sequence:
$ node
> process.stdout.write("\u001b]1337;File=;inline=1:iVBORw0KGgoAAAANSUhEUgAAABAAAAAPBAMAAAAfXVIcAAAAD1BMVEV63/39//w5TVIZFhXDjXbHNiz1AAAARUlEQVR4nJTJUQ3AIAwG4aMzsBYD9FdQEfjXtJBiYPf0JYeHJKUTC8CShYNjaMwas4xoJNHrgKdo7H0x3ovTP3wBAAD//9u1Bcrd6KY0AAAAAElFTkSuQmCC\u0007\n")
image
  1. Do the same with xterm.js and xterm-addon-image - CodeSandbox demo
image

Image was created by this Go program:


import (
    "bytes"
    "encoding/base64"
    "fmt"
    "image"
    "image/png"
)

var favicon = []byte{
    0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00,
    0x10, 0x00, 0x00, 0x00, 0x0f, 0x04, 0x03, 0x00, 0x00, 0x00, 0x1f, 0x5d, 0x52, 0x1c, 0x00, 0x00, 0x00, 0x0f, 0x50,
    0x4c, 0x54, 0x45, 0x7a, 0xdf, 0xfd, 0xfd, 0xff, 0xfc, 0x39, 0x4d, 0x52, 0x19, 0x16, 0x15, 0xc3, 0x8d, 0x76, 0xc7,
    0x36, 0x2c, 0xf5, 0x00, 0x00, 0x00, 0x40, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7, 0x95, 0xc9, 0xd1, 0x0d, 0xc0, 0x20,
    0x0c, 0x03, 0xd1, 0x23, 0x5d, 0xa0, 0x49, 0x17, 0x20, 0x4c, 0xc0, 0x10, 0xec, 0x3f, 0x53, 0x8d, 0xc2, 0x02, 0x9c,
    0xfc, 0xf1, 0x24, 0xe3, 0x31, 0x54, 0x3a, 0xd1, 0x51, 0x96, 0x74, 0x1c, 0xcd, 0x18, 0xed, 0x9b, 0x9a, 0x11, 0x85,
    0x24, 0xea, 0xda, 0xe0, 0x99, 0x14, 0xd6, 0x3a, 0x68, 0x6f, 0x41, 0xdd, 0xe2, 0x07, 0xdb, 0xb5, 0x05, 0xca, 0xdb,
    0xb2, 0x9a, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
}

func convertImage(m image.Image) string {
    var buf bytes.Buffer
    err := png.Encode(&buf, m)
    if err != nil {
        panic(err)
    }
    return base64.StdEncoding.EncodeToString(buf.Bytes())
}

func main() {
    m, err := png.Decode(bytes.NewReader(favicon))
    if err != nil {
        panic(err)
    }
    fmt.Println(displayImage(m))
}
jerch commented 7 months ago

@x1unix Plz see my answer here https://github.com/xtermjs/xterm.js/discussions/4941#discussioncomment-8131663

x1unix commented 7 months ago

@jerch thank you, closing the issue.