Skip to content

Format Specifications

awesome-llama edited this page Feb 2, 2024 · 16 revisions

This format stores images as printable text using 94 of the 95 printable ASCII characters. The one character excluded is space. In the commonly-used UTF-8 text encoding, these characters each have a size of 1 byte.

The full ordered set of characters in use, indexed 0-93:

!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Layers

An arbitrary number of layers can be specified. A layer serves a single purpose in an image, most often it is either color or transparency.

A layer conceptually consists of 5 parts:

  • purpose within the image
  • data stream type
  • data stream version (0 for all data streams currently)
  • data stream length (number of characters in the data stream by itself)
  • the data stream

One layer should be given the purpose of main which indicates it is the most important to the image and is implied that this will be the layer to display as color. Transparency is specified with the purpose of alpha. No other purpose is currently defined, it is open to custom use cases where additional layers are needed

Each data stream has corresponding properties to specify their type and usage. This enables easy expansion to support new methods beyond the 8-bit RGB and 8-bit generic lossless data streams currently implemented.

Structure

The image format begins with magic number txtimg. This follows with a comma and then these key-value pairs separated by commas. Semicolons go between the key name and value. Identical implementation to my save code format. This part of the format is known as CSKV or "comma-separated key-values".

  • version number v (currently 0)
  • image width x in pixels
  • image height y in pixels
  • list of data stream properties p containing 4 alternating property values. First value indicates the total number of items in the list. The following properties are (in this order): purpose, type, version, length.

A vertical bar (|) then indicates the data streams will follow.

Finally are the data streams, which are all concatenated without any separating character. The data stream length given in the properties allow them to be separated when needed.

Misc. Notes

Reserved characters due to their usage as separators: , : | They must not be used within keys or values.

Use of custom key names to store additional data is allowed however to avoid potential future conflicts prefix an underscore to the key name (these are reserved for custom use).

Data streams use pixels that are ordered left-to-right (x axis), bottom-to-top (y axis).

Example

The following is an example TextImage file, with explanation for some of the parts:

txtimg,v:0,x:14,y:17,p:8,main,RGB8,0,142,alpha,A8,0,101|<7?40vV53c><7)877798<7)877798<7)87779;!7H+B.D`@"Co8787779;j<7)8777953f!=J787;b77987779;!8787;!879877794e6p878787798<7N""?q!(FD<7)877798<7)8<7>!!($/T($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%($&%$$$)($&T($,%$%($,%$%($,%$%($,%($/
  • txtimg,v:0,x:14,y:17 TextImage file, version 0, dimensions 14x17
  • p:8,main,RGB8,0,142,alpha,A8,0,101 Properties containing 8 list items to follow, specifying a main RGB8 data stream that is 142 characters long and an alpha A8 data stream that is 101 characters long.
  • | The concatenated data streams follow, in the order given by the properties (RGB8 and then A8)
  • <7?40vV53c><7)877798<7)877798<7)87779;!7H+B.D`@"Co8787779;j<7)8777953f!=J787;b77987779;!8787;!879877794e6p878787798<7N""?q!(FD<7)877798<7)8<7> RGB8 data stream
  • !!($/T($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%$%($,%($&%$$$)($&T($,%$%($,%$%($,%$%($,%($/ A8 data stream

Data Streams

See Data Streams.

Clone this wiki locally