.TH "rgb2pct" 1 "Fri Mar 22 2019" "GDAL" \" -*- nroff -*- .ad l .nh .SH NAME rgb2pct \- Convert a 24bit RGB image to 8bit paletted\&. .SH "SYNOPSIS" .PP .PP .nf rgb2pct.py [-n colors | -pct palette_file] [-of format] source_file dest_file .fi .PP .SH "DESCRIPTION" .PP This utility will compute an optimal pseudo-color table for a given RGB image using a median cut algorithm on a downsampled RGB histogram\&. Then it converts the image into a pseudo-colored image using the color table\&. This conversion utilizes Floyd-Steinberg dithering (error diffusion) to maximize output image visual quality\&. .PP .IP "\fB\fB-n\fP \fIcolors\fP:\fP" 1c Select the number of colors in the generated color table\&. Defaults to 256\&. Must be between 2 and 256\&. .IP "\fB\fB-pct\fP \fIpalette_file\fP:\fP" 1c Extract the color table from \fIpalette_file\fP instead of computing it\&. Can be used to have a consistent color table for multiple files\&. The \fIpalette_file\fP must be a raster file in a GDAL supported format with a palette\&. .IP "\fB\fB-of\fP \fIformat\fP:\fP" 1c Select the output format\&. Starting with GDAL 2\&.3, if not specified, the format is guessed from the extension (previously was GTiff)\&. Use the short format name\&. Only output formats supporting pseudo-color tables should be used\&. .IP "\fB\fIsource_file\fP:\fP" 1c The input RGB file\&. .IP "\fB\fIdest_file\fP:\fP" 1c The output pseudo-colored file that will be created\&. .PP .PP NOTE: rgb2pct\&.py is a Python script, and will only work if GDAL was built with Python support\&. .SH "EXAMPLE" .PP If it is desired to hand create the palette, likely the simplest text format is the GDAL VRT format\&. In the following example a VRT was created in a text editor with a small 4 color palette with the RGBA colors 238/238/238/255, 237/237/237/255, 236/236/236/255 and 229/229/229/255\&. .PP .PP .nf % rgb2pct.py -pct palette.vrt rgb.tif pseudo-colored.tif % more < palette.vrt Palette .fi .PP .SH "AUTHOR" .PP Frank Warmerdam warmerdam@pobox.com