JPEG - revive backward compatible quality format jpeg<N> e.g jpeg80, jpeg90 etc.

ref #3024
This commit is contained in:
artemp 2015-08-11 17:13:54 +02:00
parent 6c01870397
commit b5dedd0e69

View file

@ -38,8 +38,8 @@
namespace mapnik namespace mapnik
{ {
jpeg_saver::jpeg_saver(std::ostream & stream, std::string const& t): jpeg_saver::jpeg_saver(std::ostream & stream, std::string const& t)
stream_(stream), t_(t) {} : stream_(stream), t_(t) {}
template <typename T> template <typename T>
void process_rgba8_jpeg(T const& image, std::string const& type, std::ostream & stream) void process_rgba8_jpeg(T const& image, std::string const& type, std::ostream & stream)
@ -54,6 +54,13 @@ void process_rgba8_jpeg(T const& image, std::string const& type, std::ostream &
auto const& val = kv.second; auto const& val = kv.second;
if ( key == "jpeg" ) continue; if ( key == "jpeg" ) continue;
else if ( key.size() > 4 && key.substr(0,4) == "jpeg")
{
if (!mapnik::util::string2int(key.substr(4), quality))
{
throw image_writer_exception("invalid jpeg quality: '" + key.substr(4) + "'");
}
}
else if ( key == "quality") else if ( key == "quality")
{ {
if (val && ! (*val).empty()) if (val && ! (*val).empty())