# Path: TileStache/py3_compat.py
# def is_string_type(val):


from struct import unpack, pack
from math import sqrt, ceil, log
from .py3_compat import urlopen, reduce
from operator import add
    from PIL import Image
    import Image

    "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.
"""

try:
except ImportError:
    # On some systems, PIL.Image is known as Image.

def 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.
    """

# Path: TileStache/py3_compat.py
# def is_string_type(val):


# Path: TileStache/Pixels.py
from struct import unpack, pack
from math import sqrt, ceil, log
from .py3_compat import urlopen, reduce
from operator import add
    from PIL import Image
    import Image


    "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.
"""

try:
except ImportError:
    # On some systems, PIL.Image is known as Image.

def 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.
    """

    bytes_ = urlopen(file_href).read()