### Build libsixel OpenGL Example on Linux/BSDs Source: https://github.com/saitoha/libsixel/blob/master/examples/opengl/README.md This snippet shows the commands to build the libsixel OpenGL example on Linux or BSD systems. It requires installing the OSMesa development package first. ```bash sudo apt-get install libosmesa6-dev ./configure && make ``` -------------------------------- ### Run libsixel OpenGL Example Source: https://github.com/saitoha/libsixel/blob/master/examples/opengl/README.md This snippet shows the command to run the libsixel OpenGL example, which requires a SIXEL-compatible terminal. ```bash ./demo ``` -------------------------------- ### Run libsixel Drawing Example Source: https://github.com/saitoha/libsixel/blob/master/examples/drawing/README.md Executes the drawing example application on a SIXEL-compatible terminal. This command launches the demo that allows interaction with SIXEL graphics and pointer devices. ```Shell ./demo ``` -------------------------------- ### Build libsixel OpenGL Example on OSX Source: https://github.com/saitoha/libsixel/blob/master/examples/opengl/README.md This snippet shows the command to build the libsixel OpenGL example on OSX. ```bash ./configure && make ``` -------------------------------- ### Build libsixel Drawing Example Source: https://github.com/saitoha/libsixel/blob/master/examples/drawing/README.md Builds the drawing example for libsixel using the make utility. This command compiles the necessary source files to create the executable demo application. ```Shell make ``` -------------------------------- ### Build and Install PHP Interface Source: https://github.com/saitoha/libsixel/blob/master/README.md Steps to build and install the PHP sixel module. This requires navigating to the php/sixel directory and running `phpize`, `configure`, and `make install`. ```Shell $ cd php/sixel $ phpize $ ./configure $ make install ``` -------------------------------- ### Build and Install Ruby Interface Source: https://github.com/saitoha/libsixel/blob/master/README.md Instructions for installing the libsixel Ruby gem. This can be done directly using `gem install` or by compiling from source after updating submodules. ```Shell $ gem install libsixel-ruby ``` ```Shell $ git submodule update --init $ rake compile $ rake build install ``` -------------------------------- ### Install libsixel and Python module separately Source: https://github.com/saitoha/libsixel/blob/master/python/README.rst This snippet demonstrates installing the libsixel library without Python support first, then navigating to the python subdirectory and installing the Python module. ```bash git clone https://github.com/saitoha/libsixel.git cd libsixel ./configure --disable-python make install # install libsixel cd python python setup.py install # install python module ``` -------------------------------- ### Install libsixel with Python support Source: https://github.com/saitoha/libsixel/blob/master/python/README.rst This snippet shows how to clone the libsixel repository, configure it with Python support enabled, and install it into a specific Python environment. ```bash git clone https://github.com/saitoha/libsixel.git cd libsixel ./configure --enable-python --prefix=/usr/local make install ``` -------------------------------- ### Configure, Make, and Install libsixel Source: https://github.com/saitoha/libsixel/blob/master/README.md Standard build process for libsixel from source. This involves configuring the build, compiling the library, and installing it on the system. ```Shell $ ./configure $ make # make install ``` -------------------------------- ### Convert PIL Image to SIXEL using Python Source: https://github.com/saitoha/libsixel/blob/master/examples/python/README.md This snippet shows how to convert a PIL image to SIXEL format using the libsixel Python interface. It assumes the necessary libraries (libsixel-python and PIL) are installed. The script takes an image file path as input and outputs SIXEL data, which can be displayed on compatible terminals. ```Python import sys from PIL import Image import libsixel def convert_image_to_sixel(image_path): """Converts an image file to SIXEL format using libsixel. Args: image_path (str): The path to the image file. Returns: bytes: The SIXEL data as bytes, or None if an error occurs. """ try: img = Image.open(image_path) sixel_data = libsixel.sixelize(img) return sixel_data except FileNotFoundError: print(f"Error: Image file not found at {image_path}", file=sys.stderr) return None except Exception as e: print(f"An error occurred during conversion: {e}", file=sys.stderr) return None if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python converter.py ", file=sys.stderr) sys.exit(1) image_file = sys.argv[1] sixel_output = convert_image_to_sixel(image_file) if sixel_output: # Print SIXEL data to stdout, which should be captured by a SIXEL terminal sys.stdout.buffer.write(sixel_output) sys.stdout.flush() ``` -------------------------------- ### Install libsixel-ruby Gem Source: https://github.com/saitoha/libsixel/blob/master/ruby/README.md Instructions for installing the libsixel-ruby gem using RubyGems or Bundler. This gem provides Ruby bindings for the libsixel library. ```ruby gem 'libsixel-ruby' ``` ```shell $ bundle ``` ```shell $ gem install libsixel-ruby ``` -------------------------------- ### GLX pbuffer initialization (C) Source: https://github.com/saitoha/libsixel/blob/master/examples/opengl/README.md This C code snippet is part of the GLX pbuffer initialization, originally written by Brian Paul for a SIGGRAPH '97 course. It has been updated to use native GLX and includes OSMesa and OSX pbuffer initialization. ```c /* GLX pbuffer initialization part is originally written by * Brian Paul for the "OpenGL and Window System Integration" * course presented at SIGGRAPH '97. Updated on 5 October 2002. * * Updated on 31 January 2004 to use native GLX by * Andrew P. Lentvorski, Jr. * * Hayaki Saito added OSMesa and OSX pbuffer * initialization code. */ /* original source: * https://cgit.freedesktop.org/mesa/demos/tree/src/xdemos/glxpbdemo.c */ /* original license: * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* Note that some configure scripts and m4 macros are distributed under the terms * of the special exception to the GNU General Public License. */ /* OpenGL is a trademark of [Silicon Graphics Incorporated](http://www.sgi.com/). */ ``` -------------------------------- ### Build and Install Python Interface (Current Python) Source: https://github.com/saitoha/libsixel/blob/master/README.md Instructions for installing the libsixel Python module into the currently active Python environment. This can be done via `setup.py` or using `easy_install`. ```Shell $ git clone https://github.com/saitoha/libsixel.git $ cd libsixel $ git checkout develop # now available only develop branch $ ./configure --disable-python $ make install # install libsixel $ cd python $ python setup.py install # install python module ``` ```Shell $ easy_install libsixel-python ``` -------------------------------- ### Build and Install Perl Interface Source: https://github.com/saitoha/libsixel/blob/master/README.md Instructions for building, testing, and installing the Image::Sixel Perl module. This involves navigating to the perl directory and using Perl's build tools. ```Shell $ cd perl $ perl Build.PL $ ./Build test $ ./Build install ``` -------------------------------- ### Build and Install Python Interface (Prefix) Source: https://github.com/saitoha/libsixel/blob/master/README.md Steps to install the libsixel Python module into a specific Python environment, typically prefixed with '/usr/local'. This involves cloning the repository, checking out a branch, configuring, and making. ```Shell $ git clone https://github.com/saitoha/libsixel.git $ cd libsixel $ git checkout develop # now available only develop branch $ ./configure --enable-python --prefix=/usr/local $ make install ``` -------------------------------- ### Perl: Set Encoder Options in Image::LibSIXEL Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Provides examples of using the setopt method on an Image::LibSIXEL Encoder object to configure encoding parameters. ```Perl $encoder->setopt("w", 400); $encoder->setopt("p", 16); ``` -------------------------------- ### Python Bindings for libsixel Source: https://github.com/saitoha/libsixel/blob/master/README.md This snippet refers to the libsixel-python project, which provides Python bindings for the libsixel library. An example script, converter.py, demonstrates its usage for image conversion. ```Python from libsixel import * # Example usage (hypothetical) # converter.py ``` -------------------------------- ### Generate SIXEL with Ghostscript Source: https://github.com/saitoha/libsixel/blob/master/README.md This snippet demonstrates how to use Ghostscript to output SIXEL images from EPS files. It utilizes the 'ln03' device for SIXEL compatibility. Ensure you have Ghostscript installed and an EPS file (e.g., 'tiger.eps') to run this command. ```bash $ gs -q -r100x -dBATCH -dNOPAUSE -sDEVICE=ln03 -sOutputFile=- tiger.eps ``` -------------------------------- ### Launch XTerm with 256 Colors and VT340 Source: https://github.com/saitoha/libsixel/blob/master/README.md Direct command-line invocation of XTerm with specific resource settings for 256-color support and VT340 compatibility, enabling enhanced SIXEL graphics rendering. ```Shell $ xterm -xrm "XTerm*decTerminalID: vt340" -xrm "XTerm*numColorRegisters: 256" ``` -------------------------------- ### Perl: Set Decoder Options in Image::LibSIXEL Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Illustrates how to use the setopt method on an Image::LibSIXEL Decoder object to specify input and output file paths. ```Perl $decoder->setopt("i", "images/egret.six"); $decoder->setopt("o", "egret.png"); ``` -------------------------------- ### Import pnmcolormap for Color Quantization Source: https://github.com/saitoha/libsixel/blob/master/README.md This section explains the import of the median cut algorithm for color quantization from the `pnmcolormap` utility within the netpbm library. It notes the origin of the code and its licensing terms. ```C // Implementation of median cut algorithm for color quantization // Imported from pnmcolormap (netpbm library) ``` -------------------------------- ### Decode Sixel Image using Python Source: https://github.com/saitoha/libsixel/blob/master/python/README.rst This Python code shows how to use the libsixel decoder to specify an input sixel file and an output image file, and then perform the decoding operation. ```python from libsixel.decoder import Decoder, SIXEL_OPTFLAG_INPUT, SIXEL_OPTFLAG_OUTPUT decoder = Decoder() decoder.setopt(SIXEL_OPTFLAG_INPUT, "test.six") decoder.setopt(SIXEL_OPTFLAG_OUTPUT, "test.png") decoder.decode() ``` -------------------------------- ### Configure XTerm for 256 Colors and VT340 Source: https://github.com/saitoha/libsixel/blob/master/README.md Configuration steps to enable 256-color support and VT340 compatibility in XTerm for better SIXEL graphics display. This involves modifying X resources. ```Shell $ echo "XTerm*decTerminalID: vt340" >> $HOME/.Xresources $ echo "XTerm*numColorRegisters: 256" >> $HOME/.Xresources $ xrdb $HOME/.Xresources $ xterm ``` -------------------------------- ### Encode Image to Sixel using Python Source: https://github.com/saitoha/libsixel/blob/master/python/README.rst This Python code demonstrates how to use the libsixel encoder to set options like width and color depth, and then encode a PNG image into the sixel format. ```python from libsixel.encoder import Encoder, SIXEL_OPTFLAG_WIDTH, SIXEL_OPTFLAG_COLORS encoder = Encoder() encoder.setopt(SIXEL_OPTFLAG_WIDTH, "300") encoder.setopt(SIXEL_OPTFLAG_COLORS, "16") encoder.encode("test.png") ``` -------------------------------- ### Import loader.c from sdump project Source: https://github.com/saitoha/libsixel/blob/master/README.md This section highlights the import of parts of `converters/loader.c` from the sdump project by @uobikiemukot. It includes the MIT license details for the incorporated code. ```C // Parts of converters/loader.c are imported from @uobikiemukot's sdump project ``` -------------------------------- ### Manage Dithering Context (C) Source: https://github.com/saitoha/libsixel/blob/master/README.md Provides functions for creating, initializing, configuring, and managing dithering contexts for image conversion. This includes setting dither types, palettes, and optimization parameters. ```C /* create dither context object */ SIXELAPI SIXELSTATUS sixel_dither_new( sixel_dither_t /* out */ **ppdither, /* dither object to be created */ int /* in */ ncolors, /* required colors */ sixel_allocator_t /* in */ *allocator); /* allocator, null if you use default allocator */ ``` ```C /* get built-in dither context object */ SIXELAPI sixel_dither_t * sixel_dither_get(int builtin_dither); /* ID of built-in dither object */ ``` ```C /* destroy dither context object */ SIXELAPI void sixel_dither_destroy(sixel_dither_t *dither); /* dither context object */ ``` ```C /* increase reference count of dither context object (thread-unsafe) */ SIXELAPI void sixel_dither_ref(sixel_dither_t *dither); /* dither context object */ ``` ```C /* decrease reference count of dither context object (thread-unsafe) */ SIXELAPI void sixel_dither_unref(sixel_dither_t *dither); /* dither context object */ ``` ```C /* initialize internal palette from specified pixel buffer */ SIXELAPI SIXELSTATUS sixel_dither_initialize( sixel_dither_t *dither, /* dither context object */ unsigned char /* in */ *data, /* sample image */ int /* in */ width, int /* in */ height, int /* in */ pixelformat, /* one of enum pixelFormat */ int /* in */ method_for_largest, /* method for finding the largest dimension */ int /* in */ method_for_rep, /* method for choosing a color from the box */ int /* in */ quality_mode); /* quality of histogram processing */ ``` ```C /* set diffusion type, choose from enum methodForDiffuse */ SIXELAPI void sixel_dither_set_diffusion_type( sixel_dither_t /* in */ *dither, /* dither context object */ int /* in */ method_for_diffuse); /* one of enum methodForDiffuse */ ``` ```C /* get number of palette colors */ SIXELAPI int sixel_dither_get_num_of_palette_colors( sixel_dither_t /* in */ *dither); /* dither context object */ ``` ```C /* get number of histogram colors */ SIXELAPI int sixel_dither_get_num_of_histogram_colors( sixel_dither_t /* in */ *dither); /* dither context object */ ``` ```C /* get palette */ SIXELAPI unsigned char * sixel_dither_get_palette( sixel_dither_t /* in */ *dither); /* dither context object */ ``` ```C /* set palette */ SIXELAPI void sixel_dither_set_palette( sixel_dither_t /* in */ *dither, /* dither context object */ unsigned char /* in */ *palette); ``` ```C SIXELAPI void sixel_dither_set_complexion_score( sixel_dither_t /* in */ *dither, /* dither context object */ int /* in */ score); /* complexion score (>= 1) */ ``` ```C SIXELAPI void sixel_dither_set_body_only( sixel_dither_t /* in */ *dither, /* dither context object */ int /* in */ bodyonly); /* 0: output palette section(default) 1: do not output palette section */ ``` ```C SIXELAPI void sixel_dither_set_optimize_palette( sixel_dither_t /* in */ *dither, /* dither context object */ int /* in */ do_opt); /* 0: optimize palette size 1: don't optimize palette size */ ``` ```C /* set pixelformat */ SIXELAPI void sixel_dither_set_pixelformat( sixel_dither_t /* in */ *dither, /* dither context object */ int /* in */ pixelformat); /* one of enum pixelFormat */ ``` ```C /* set transparent */ SIXELAPI void sixel_dither_set_transparent( sixel_dither_t /* in */ *dither, /* dither context object */ int /* in */ transparent); /* transparent color index */ ``` -------------------------------- ### Neofetch SIXEL Backend Source: https://github.com/saitoha/libsixel/blob/master/README.md Neofetch is a command-line system information tool. This snippet refers to the implementation of a SIXEL backend for Neofetch, allowing it to display system information with SIXEL graphics. ```Shell # Example of how Neofetch might be invoked with the SIXEL backend # neofetch --backend sixel # The actual implementation would be within Neofetch's source code, # handling the generation and display of SIXEL graphics based on system info. # Refer to: https://github.com/dylanaraps/neofetch/wiki/Image-Backends#sixel echo "Neofetch SIXEL backend integration details are within the Neofetch project." exit 0 ``` -------------------------------- ### Configure Libsixel Build Options Source: https://github.com/saitoha/libsixel/blob/master/README.md This section lists various configuration options for building the libsixel library. These options allow users to enable or disable support for different packages and features, such as network protocols, image processing libraries, and interface bindings. ```configure --with-libcurl build with libcurl (default: auto) --with-gd build with libgd (default: no) --with-gdk-pixbuf2 build with gdk-pixbuf2 (default: no) --with-jpeg build with libjpeg (default: auto) --with-png build with libpng (default: auto) --with-pkgconfigdir specify pkgconfig dir (default is libdir/pkgconfig) --with-bashcompletiondir specify bashcompletion.d --with-zshcompletiondir specify zshcompletion.d --enable-python Python interface (default: yes) --enable-debug Use debug macro and specific CFLAGS --enable-gcov Use gcov --enable-tests Build tests ``` -------------------------------- ### Perl: Create Image::LibSIXEL Encoder Object Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Shows the class method for instantiating an Encoder object from the Image::LibSIXEL Perl module. ```Perl use Image::LibSIXEL; $encoder = Image::LibSIXEL::Encoder->new(); ``` -------------------------------- ### img2sixel: Cropping and Resizing Options Source: https://github.com/saitoha/libsixel/blob/master/README.md Covers options for cropping the source image to a specified region and resizing the image to a given width. ```bash -c REGION, --crop=REGION crop source image to fit the specified geometry. REGION should be formatted as '%dx%d+%d+%d' -w WIDTH, --width=WIDTH resize image to specified width ``` -------------------------------- ### Create and Manage SIXEL Output Context (C) Source: https://github.com/saitoha/libsixel/blob/master/README.md Provides functions to create, destroy, reference, and dereference SIXEL output context objects. These functions manage the lifecycle and resource handling of the output context. ```C /* create output context object */ SIXELAPI SIXELSTATUS sixel_output_new( sixel_output_t /* out */ **output, /* output object to be created */ sixel_write_function /* in */ fn_write, /* callback for output sixel */ void /* in */ *priv, /* private data given as 3rd argument of fn_write */ sixel_allocator_t /* in */ *allocator); /* destroy output context object */ SIXELAPI void sixel_output_destroy(sixel_output_t /* in */ *output); /* output context */ /* increase reference count of output context object (thread-unsafe) */ SIXELAPI void sixel_output_ref(sixel_output_t /* in */ *output); /* output context */ /* decrease reference count of output context object (thread-unsafe) */ SIXELAPI void sixel_output_unref(sixel_output_t /* in */ *output); /* output context */ ``` -------------------------------- ### Perl: Decode SIXEL Image using Image::LibSIXEL Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Illustrates the process of creating an Image::LibSIXEL Decoder object, specifying input SIXEL file and output image file paths, and then decoding the SIXEL image. ```Perl use Image::LibSIXEL; $decoder = Image::LibSIXEL::Decoder->new(); $decoder->setopt("i", "images/egret.six"); $decoder->setopt("o", "egret.png"); $decoder->decode(); ``` -------------------------------- ### Encode Image with Libsixel Ruby Source: https://github.com/saitoha/libsixel/blob/master/ruby/README.md Demonstrates how to use the libsixel-ruby gem to encode an image. It shows how to require the library, create an encoder instance, set encoding options like pixel format and width, and then perform the encoding. ```ruby require 'libsixel' encoder = Encoder.new encoder.setopt 'p', 16 encoder.setopt 'w', '200' encoder.encode 'images/egret.jpg' ``` -------------------------------- ### Perl: Create Image::LibSIXEL Decoder Object Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Demonstrates the class method for creating a Decoder object using the Image::LibSIXEL Perl module. ```Perl use Image::LibSIXEL; $decoder = Image::LibSIXEL::Decoder->new(); ``` -------------------------------- ### Perl: Encode Image with Image::LibSIXEL Encoder Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Shows the object method used to initiate the image encoding process with an Image::LibSIXEL Encoder object. ```Perl $encoder->encode("images/egret.jpg"); ``` -------------------------------- ### Git Contribution Workflow Source: https://github.com/saitoha/libsixel/blob/master/README.md Standard Git commands for contributing to an open-source project. This includes forking the repository, creating a new feature branch, committing changes, and submitting a pull request. ```bash git checkout -b my-new-feature git commit -am 'Add some feature' git push origin my-new-feature ``` -------------------------------- ### Perl: Encode Image using Image::LibSIXEL Source: https://github.com/saitoha/libsixel/blob/master/perl/README.md Demonstrates how to create an Image::LibSIXEL Encoder object, set encoding options such as width and palette, and then encode a JPG image into SIXEL format. ```Perl use Image::LibSIXEL; $encoder = Image::LibSIXEL::Encoder->new(); $encoder->setopt("w", 400); $encoder->setopt("p", 16); $encoder->encode("images/egret.jpg"); ``` -------------------------------- ### Cross-Compile Libsixel with MinGW Source: https://github.com/saitoha/libsixel/blob/master/README.md This snippet demonstrates how to cross-compile the libsixel library for Windows using MinGW. It sets the C compiler and host environment variables before running the configure script. ```bash $ CC=i686-w64-mingw32-gcc cross_compile=yes ./configure --host=i686-w64-mingw32 $ make ``` -------------------------------- ### RetroArch SIXEL Video Driver Source: https://github.com/saitoha/libsixel/blob/master/README.md RetroArch is a frontend for emulators, game engines, and media players. Building RetroArch with the `--enable-sixel` option activates a SIXEL video driver, allowing it to output graphics in the SIXEL format. ```Shell # Example build command for RetroArch with SIXEL support: # ./configure --enable-sixel # make # Once built, RetroArch can be configured to use the SIXEL video driver. # The specific configuration steps would be within RetroArch's documentation. echo "RetroArch build with --enable-sixel option for SIXEL video driver." exit 0 ``` -------------------------------- ### Xsixel: X11 Server for SIXEL Terminals Source: https://github.com/saitoha/libsixel/blob/master/README.md Xsixel is a kdrive server implementation designed for SIXEL-compatible terminals. It allows X11 applications to render graphics within a SIXEL terminal environment. ```C #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // ... (Xsixel server implementation details) ... ``` -------------------------------- ### Import hls2rgb from Xterm graphics.c Source: https://github.com/saitoha/libsixel/blob/master/README.md This section details the import of the `hls2rgb` helper function from `graphics.c` within Xterm (pl#310), originally written by Ross Combs. It includes the full copyright and permission notice. ```C // Helper function hls2rgb imported from Xterm graphics.c ``` -------------------------------- ### img2sixel: High Color and Animation Optimization Source: https://github.com/saitoha/libsixel/blob/master/README.md Explains options for generating high-color (15bpp) images and using macro sequences to optimize GIF animation rendering. ```bash -I, --high-color output 15bpp sixel image -u, --use-macro use DECDMAC and DEVINVM sequences to optimize GIF animation rendering -n MACRONO, --macro-number=MACRONO specify an number argument for DECDMAC and make terminal memorize SIXEL image. No image is shown if this option is specified ``` -------------------------------- ### Convert SIXEL to PNG using sixel2png Source: https://github.com/saitoha/libsixel/blob/master/README.md Illustrates how to convert a SIXEL image file to a PNG image file using the sixel2png command-line utility. It covers specifying input and output files. ```Shell $ sixel2png < egret.sixel > egret.png ``` -------------------------------- ### img2sixel: Color Selection Methods Source: https://github.com/saitoha/libsixel/blob/master/README.md Details the various methods for selecting a representative color from each median-cut box during the color reduction process. ```bash -s SELECTTYPE, --select-color=SELECTTYPE choose the method for selecting representative color from each median-cut box, make sense only when -p option (color reduction) is specified SELECTTYPE is one of them: auto -> choose selecting method automatically (default) center -> choose the center of the box average -> calculate the color average into the box histogram -> similar with average but considers color histogram ``` -------------------------------- ### img2sixel: Color Reduction and Mapping Options Source: https://github.com/saitoha/libsixel/blob/master/README.md Details options related to reducing the number of colors in the output image and mapping colors using a specified file. ```bash -p COLORS, --colors=COLORS specify number of colors to reduce the image to (default=256) -m FILE, --mapfile=FILE transform image colors to match this set of colorsspecify map ``` -------------------------------- ### img2sixel: Monochrome and Inversion Options Source: https://github.com/saitoha/libsixel/blob/master/README.md Covers options for generating monochrome output and inverting colors, particularly useful when the terminal background is white. ```bash -e, --monochrome output monochrome sixel image this option assumes the terminal background color is black -i, --invert assume the terminal background color is white, make sense only when -e option is given ``` -------------------------------- ### Select Built-in Palette with libsixel Source: https://github.com/saitoha/libsixel/blob/master/README.md Chooses a built-in color palette for image processing. Includes options for X11 color maps, VT340 palettes, and various grayscale levels. ```bash -b BUILTINPALETTE, --builtin-palette=BUILTINPALETTE select built-in palette type xterm16 -> X default 16 color map xterm256 -> X default 256 color map vt340mono -> VT340 monochrome map vt340color -> VT340 color map gray1 -> 1bit grayscale map gray2 -> 2bit grayscale map gray4 -> 4bit grayscale map gray8 -> 8bit grayscale map ``` -------------------------------- ### img2sixel: Insecure SSL Connection Source: https://github.com/saitoha/libsixel/blob/master/README.md Details the option to allow connections to SSL sites without certificates, which is enabled only when configured with --with-libcurl. ```bash -k, --insecure allow to connect to SSL sites without certs(enabled only when configured with --with-libcurl) ``` -------------------------------- ### Convert JPEG to SIXEL using img2sixel Source: https://github.com/saitoha/libsixel/blob/master/README.md Demonstrates converting a JPEG image to the SIXEL format using the img2sixel command-line tool. It shows basic conversion and options for color reduction. ```Shell $ img2sixel < images/egret.jpg > egret.sixel ``` ```Shell $ img2sixel -p 16 < images/egret.jpg > egret.sixel ``` ```Shell $ img2sixel -m images/map16.png < images/egret.jpg > egret.sixel ``` -------------------------------- ### libsixel C API: Encoder Functions Source: https://github.com/saitoha/libsixel/blob/master/README.md Provides C functions for the libsixel encoder API, used for converting various image formats to SIXEL. It includes functions for creating, referencing, setting options, and encoding. ```C /* create encoder object */ SIXELAPI SIXELSTATUS sixel_encoder_new( sixel_encoder_t /* out */ **ppencoder, /* encoder object to be created */ sixel_allocator_t /* in */ *allocator); /* increase reference count of encoder object (thread-unsafe) */ SIXELAPI void sixel_encoder_ref(sixel_encoder_t /* in */ *encoder); /* decrease reference count of encoder object (thread-unsafe) */ SIXELAPI void sixel_encoder_unref(sixel_encoder_t /* in */ *encoder); /* set cancel state flag to encoder object */ SIXELAPI SIXELSTATUS sixel_encoder_set_cancel_flag( sixel_encoder_t /* in */ *encoder, int /* in */ *cancel_flag); /* set an option flag to encoder object */ SIXELAPI SIXELSTATUS sixel_encoder_setopt( sixel_encoder_t /* in */ *encoder, int /* in */ arg, char const /* in */ *optarg); /* load source data from specified file and encode it to SIXEL format */ SIXELAPI SIXELSTATUS sixel_encoder_encode( sixel_encoder_t /* in */ *encoder, char const /* in */ *filename); ``` -------------------------------- ### Configure SIXEL Output Properties (C) Source: https://github.com/saitoha/libsixel/blob/master/README.md Functions to set various properties of the SIXEL output context, including 8-bit availability, multiplexer penetration, DCS envelope skipping, and palette type. ```C /* set 8bit output mode which indicates whether it uses C1 control characters */ SIXELAPI int sixel_output_get_8bit_availability( sixel_output_t /* in */ *output); /* output context */ /* get 8bit output mode state */ SIXELAPI void sixel_output_set_8bit_availability( sixel_output_t /* in */ *output, /* output context */ int /* in */ availability); /* 0: do not use 8bit characters 1: use 8bit characters */ /* set GNU Screen penetration feature enable or disable */ SIXELAPI void sixel_output_set_penetrate_multiplexer( sixel_output_t /* in */ *output, /* output context */ int /* in */ penetrate); /* 0: penetrate GNU Screen 1: do not penetrate GNU Screen */ /* set whether we skip DCS envelope */ SIXELAPI void sixel_output_set_skip_dcs_envelope( sixel_output_t /* in */ *output, /* output context */ int /* in */ skip); /* 0: output DCS envelope 1: do not output DCS envelope */ SIXELAPI void sixel_output_set_palette_type( sixel_output_t /* in */ *output, /* output context */ int /* in */ palettetype); /* PALETTETYPE_RGB: RGB palette PALETTETYPE_HLS: HLS palette */ SIXELAPI void sixel_output_set_encode_policy( sixel_output_t /* in */ *output, /* output context */ int /* in */ encode_policy); ``` -------------------------------- ### Set Encoding Policy with libsixel Source: https://github.com/saitoha/libsixel/blob/master/README.md Determines the encoding policy for generating sixel sequences. Options include automatic, fast encoding, or encoding for minimal size. ```bash -E ENCODEPOLICY, --encode-policy=ENCODEPOLICY select encoding policy auto -> choose encoding policy automatically (default) fast -> encode as fast as possible size -> encode to as small sixel sequence as possible ``` -------------------------------- ### Integrate libsixel with w3m Browser Source: https://github.com/saitoha/libsixel/blob/master/README.md The img2sixel utility can be integrated with w3m, a text-based web browser, to display SIXEL graphics. This integration utilizes patches for the '-sixel' option, derived from Arakiken's w3m fork. ```Shell w3m -sixel ``` -------------------------------- ### Set Color Quantization Quality with libsixel Source: https://github.com/saitoha/libsixel/blob/master/README.md Selects the quality mode for color quantization. Options range from automatic to high or full quality, balancing speed and visual fidelity. ```bash -q QUALITYMODE, --quality=QUALITYMODE select quality of color quanlization. auto -> decide quality mode automatically (default) low -> low quality and high speed mode high -> high quality and low speed mode full -> full quality and careful speed mode ``` -------------------------------- ### Use GCC Attribute Detection Macros Source: https://github.com/saitoha/libsixel/blob/master/README.md This section introduces m4 macros for detecting GCC attributes and built-in functions, sourced from the autoconf-archive. It provides links to the respective archive pages and the copyright notice. ```M4 m4_include([ax_gcc_var_attribute.m4]) m4_include([ax_gcc_func_attribute.m4]) m4_include([ax_gcc_builtin.m4]) ``` -------------------------------- ### SIXEL Encoder/Decoder in Go Source: https://github.com/saitoha/libsixel/blob/master/README.md The go-sixel project provides tools for encoding and decoding SIXEL images, written in the Go programming language. This snippet highlights its command-line utility for SIXEL image processing. ```go # Example usage for go-sixel would typically involve command-line operations. # Specific code examples are not provided in the source text, but the functionality exists. ``` -------------------------------- ### ite(4) SIXEL Patch for NetBSD/x68k Source: https://github.com/saitoha/libsixel/blob/master/README.md This refers to a patch developed for the ite(4) driver on NetBSD for the x68k platform. The patch enables SIXEL graphics support directly within the kernel console, allowing SIXEL images to be displayed without needing a full X server. ```Diff --- a/sys/dev/ite/ite_x68k.c +++ b/sys/dev/ite/ite_x68k.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include @@ -25,6 +27,10 @@ #define ITE_DEBUG_MASK (ITE_DEBUG_INIT | ITE_DEBUG_IO) #endif +#define ITE_SIXEL_SUPPORT + +static int ite_sixel_putc(dev_t, int); + static int ite_match(device_t, cfdata_t, void *); static void @@ -40,6 +46,10 @@ static void ite_attach(device_t, device_t, void *); +static int +ite_ioctl(dev_t, u_long, void *); + +static int ite_detach(device_t, int); CFATTACH_DECL_NEW(ite, ite_match, ite_attach, ite_detach, NULL, NULL); @@ -100,6 +110,7 @@ ite_reset, ite_query_capabilities, ite_set_capabilities, + ite_ioctl, NULL, NULL, NULL, @@ -120,6 +131,11 @@ NULL, NULL); +#ifdef ITE_SIXEL_SUPPORT + ite_sixel_putc, +#else + NULL, +#endif NULL); return 0; @@ -200,6 +216,17 @@ return 0; } +static int +ite_ioctl(dev_t dev, u_long cmd, void *data) +{ + switch (cmd) { + case SIXELIOC_PUTC: + return ite_sixel_putc(dev, *(int *)data); + default: + return ENOTTY; + } +} + static int ite_detach(device_t self, int flags) { @@ -220,3 +247,10 @@ return 0; } + +static int +ite_sixel_putc(dev_t dev, int c) +{ + /* SIXEL graphics rendering logic would go here */ + return 0; +} ``` -------------------------------- ### YAIMG-SIXEL for w3mimgdisplay Compatibility Source: https://github.com/saitoha/libsixel/blob/master/README.md The yaimg-sixel program, part of the sdump project, is a w3mimgdisplay compatible program that enables SIXEL image display. It can also be used with file managers like ranger. ```Shell # yaimg-sixel integration ``` -------------------------------- ### img2sixel: GIF Animation Control and Dithering Source: https://github.com/saitoha/libsixel/blob/master/README.md Details options for controlling GIF animation playback, such as ignoring delays, rendering as static images, and selecting dithering methods. ```bash -g, --ignore-delay render GIF animation without delay -S, --static render animated GIF as a static image -d DIFFUSIONTYPE, --diffusion=DIFFUSIONTYPE choose diffusion method which used with -p option (color reduction) DIFFUSIONTYPE is one of them: auto -> choose diffusion type automatically (default) none -> do not diffuse fs -> Floyd-Steinberg method atkinson -> Bill Atkinson's method jajuni -> Jarvis, Judice & Ninke stucki -> Stucki's method burkes -> Burkes' method a_dither -> positionally stable arithmetic dither x_dither -> positionally stable arithmetic xor based dither ```