MyNixOS website logo
Description

Encoding and Decoding Sixel Images.

Provides a native R implementation for encoding and decoding 'sixel' graphics (<https://vt100.net/docs/vt3xx-gp/chapter14.html>), and a dedicated 'sixel' graphics device that allows plots to be rendered directly within compatible terminal emulators.

rsixel

SIXEL image encoding / decoding for R.

Installation

pak::pak("Fan-iX/rsixel")

You may also need jpeg, png or magick package to read image files.

Usage

SIXEL graphics device

The sixel() function creates a graphics device that outputs SIXEL sequences to the console when closed. This allows you to display plots directly in terminals that support SIXEL graphics.

library(rsixel)
sixel()
plot(iris$Petal.Width, iris$Petal.Length)
dev.off()

The sixel sequence of the plot will be printed to the console after dev.off().

[!NOTE] You need a terminal emulator that support SIXEL graphics format to see the result.

Encoding an image to sixel format

library(rsixel)
image <- png::readPNG("path/to/image.png")
# For example, the R logo from the `png` package:
# image <- png::readPNG(system.file("img", "Rlogo.png", package="png"))
sixel_sequence <- sixelEncode(image, max.colors = 256, iter.max = 10)
cat(sixel_sequence)

A helper function, imgcat, is provided to preview images in R sessions directly.

library(rsixel)
imgcat("path/to/image.png")
# imgcat(system.file("img", "Rlogo.png", package="png"))

png("mpg.png")
ggplot2::qplot(mpg, wt, data = mtcars, colour = cyl)
dev.off()
imgcat("mpg.png")

Decoding sixel sequence to an image

sixel_file <- system.file("snake.six", package="rsixel")
sixel_data <- readChar(sixel_file, file.size(sixel_file))
img <- sixelDecode(sixel_data)

You can also use readSIXEL to read a SIXEL file directly.

img <- readSIXEL(system.file("snake.six", package="rsixel"))
Metadata

Version

0.0.4

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows