.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "RGB2PCT" "1" "Aug 18, 2026" "" "GDAL" .SH NAME rgb2pct \- Convert a 24bit RGB image to 8bit paletted. .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX rgb2pct [\-\-help] [\-\-help\-general] [\-\-creation\-option OPTION] [\-n colors | \-pct palette_file] [\-of format] .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp 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. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 rgb2pct is a Python utility, and is only available if GDAL Python bindings are available. .UNINDENT .UNINDENT .sp \fBTIP:\fP .INDENT 0.0 .INDENT 3.5 Equivalent in new \(dqgdal\(dq command line interface: .sp See \fI\%gdal raster rgb\-to\-palette\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \-\-help Show this help message and exit .UNINDENT .INDENT 0.0 .TP .B \-\-help\-general Gives a brief usage message for the generic GDAL commandline options and exit. .UNINDENT .INDENT 0.0 .TP .B \-n Select the number of colors in the generated color table. Defaults to 256. Must be between 2 and 256. .UNINDENT .INDENT 0.0 .TP .B \-\-creation\-option OPTION Optional creation parameters for the GeoTIFF driver, for example \(dqCOMPRESS=LZW\(dq. Can be specified multiple times. .UNINDENT .INDENT 0.0 .TP .B \-pct Extract the color table from instead of computing it. Can be used to have a consistent color table for multiple files. The must be either a raster file in a GDAL supported format with a palette or a color file in a supported format (txt, qml, qlr). .UNINDENT .INDENT 0.0 .TP .B \-of Select the output format. If not specified, the format is guessed from the extension. Use the short format name. Only output formats supporting pseudo\-color tables should be used. .UNINDENT .INDENT 0.0 .TP .B The input RGB file. .UNINDENT .INDENT 0.0 .TP .B The output pseudo\-colored file that will be created. .UNINDENT .SH RETURN STATUS CODE .sp The program returns status code 0 in case of success, and non\-zero in case of error (non\-blocking errors emitted as warnings are considered as a successful execution). .SH EXAMPLE .sp 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. .INDENT 0.0 .INDENT 3.5 .sp .EX $ rgb2pct \-pct palette.vrt rgb.tif pseudo\-colored.tif $ more < palette.vrt Palette .EE .UNINDENT .UNINDENT .SH AUTHOR Frank Warmerdam .SH COPYRIGHT 1998-2026 .\" Generated by docutils manpage writer. .