Python: module TileStache.Pixels

TileStache.Pixels | index

`Support for 8-bit image palettes in PNG output.
PNG images can be significantly cut down in size by using a color look-up table.
TileStache layers support Adobe Photoshop's .act file format for PNG output,
and can be referenced in a layer configuration file like this:
"osm":
{
"provider": {"name": "proxy", "provider": "OPENSTREETMAP"},
"png options": {"palette": "http://tilestache.org/example-palette-openstreetmap-mapnik.act"}
}
The example OSM palette above is a real file with a 32 color (5 bit) selection
of colors appropriate for use with OpenStreetMap's default Mapnik cartography.
To generate an .act file, convert an existing image in Photoshop to indexed
color, and access the color table under Image -> Mode -> Color Table. Saving
the color table results in a usable .act file, internally structured as a
fixed-size 772-byte table with 256 3-byte RGB triplets, followed by a two-byte
unsigned int with the number of defined colors (may be less than 256) and a
finaly two-byte unsigned int with the optional index of a transparent color
in the lookup table. If the final byte is 0xFFFF, there is no transparency.`

Modules
`` |  |
PIL.Image |  |  |

Functions
`` |  | add(...) `add(a, b) -- Same as a + b.` apply_palette(image, palette, t_index) `Apply a palette array to an image, return a new image.` apply_palette256(image) `Get PIL to generate and apply an optimum 256 color palette to the given image and return it` ceil(...) `ceil(x) Return the ceiling of x as a float. This is the smallest integral value >= x.` load_palette(file_href) `Load colors from a Photoshop .act file, return palette info. Return tuple is an array of [ (r, g, b), (r, g, b), ... ], bit depth of the palette, and a numeric transparency index or None if not defined.` log(...) `log(x[, base]) Return the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x.` pack(...) `Return string containing values v1, v2, ... packed according to fmt.` palette_color(r, g, b, palette, t_index) `Return best palette match index. Find the closest color in the palette based on dumb euclidian distance, assign its index in the palette to a mapping from 24-bit color tuples.` sqrt(...) `sqrt(x) Return the square root of x.` unpack(...) `Unpack the string containing packed C structure data, according to fmt. Requires len(string) == calcsize(fmt).`