artemp/mapnik — Issue #896: python image.tostring("jpeg") fails with 'palette unsupported' error
Author: artemp
Created: 2011-10-11 16:41:29+00:00
State: open

After upgrading the OSM tile server to mapink-2.0.0 the export script started returning the error below:
{{{
Traceback (most recent call last):
File "/usr/lib/cgi-bin/export", line 135, in
jpeg = image.tostring("jpeg")
RuntimeError: palettes are not currently supported when writing to jpeg format
}}}
This seems to fix it by removing the unnecessary empty palette from tostring2:
{{{
--- ./bindings/python/mapnik_image.cpp~ 2011-09-26 11:30:24.000000000 +0100
+++ ./bindings/python/mapnik_image.cpp 2011-10-02 18:06:18.000000000 +0100
@@ -79,8 +79,7 @@
// encode (png,jpeg)
PyObject* tostring2(image_32 const & im, std::string const& format)
{
- mapnik::rgba_palette pal;
- std::string s = save_to_string(im, format, pal);
+ std::string s = save_to_string(im, format);
return
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
}}}
A similar fix is probably required for image views in view_tostring2