[MapProxy] Output colors always reduced with PNG24 source

Martin Kokeš shr3k at typo3-hosting.com
Sun Mar 31 05:06:30 PDT 2013


Hello list,


I have following config (MP 1.5, PIL from Oliver's source):
---

services:
  demo:
  kml:
  tms:
  wmts:
  wms:
    srs: ["EPSG:900913"]
    image_formats: ["image/png"]


layers:


  - name: test1
    title: Test with PNG24 source
    sources: [test1_cache]
  - name: test2
    title: Test with JPEG source
    sources: [test2_cache]


caches:


  test1_cache:
    sources: [test1_wms]
    grids: [global_mercator_osm]
    format: png24
    cache:
      type: file


  test2_cache:
    sources: [test2_wms]
    grids: [global_mercator_osm]
    format: png24
    cache:
      type: file


sources:


  test1_wms:
    type: wms
    req:
      url: http://geoportal.cuzk.cz/WMS_ZM10_PUB/service.svc/get
      layers: GR_ZM10
      format: image/png
      transparent: false
    coverage:
      bbox: [11.214011580382529, 47.964914601259672, 19.407662623095131, 51.691664934538636]
      srs: 'EPSG:4326'
    supported_srs: ['EPSG:5514']
    min_scale: 2.5253813613805272
    max_scale: 7576144.0841415804
    http:
      client_timeout: 300


  test2_wms:
    type: wms
    req:
      url: http://geoportal.cuzk.cz/WMS_ZM10_PUB/service.svc/get
      layers: GR_ZM10
      format: image/jpeg
      transparent: false
    coverage:
      bbox: [11.214011580382529, 47.964914601259672, 19.407662623095131, 51.691664934538636]
      srs: 'EPSG:4326'
    supported_srs: ['EPSG:5514']
    min_scale: 2.5253813613805272
    max_scale: 7576144.0841415804
    http:
      client_timeout: 300


grids:
  global_mercator_osm:
    base: GLOBAL_MERCATOR
    num_levels: 20


globals:
  srs:
    proj_data_dir: "proj_data"
  image:
    paletted: false
    formats:
      png24:
        format: image/png
        mode: RGB
        colors: 0
        transparent: false
        resampling_method: bicubic
---
This is source request for test1:
http://geoportal.cuzk.cz/WMS_ZM10_PUB/service.svc/get?styles=&format=image%2Fpng&height=1184&bbox=-742076.617816,-1045120.38486,-741052.456103,-1044098.3743&transparent=False&layers=GR_ZM10&service=WMS&width=1186&request=GetMap&srs=EPSG%3A5514&version=1.1.1


Sometimes I become this error:

[2013-03-31 13:59:19,391] mapproxy.wsgiapp - CRITICAL - fatal error in tms for /tms/1.0.0/test1_EPSG900913/16/70795/86663.png
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/wsgiapp.py", line 166, in __call__
    resp = self.handlers[handler_name].handle(req)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/service/base.py", line 30, in handle
    return handler(parsed_req)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/service/tile.py", line 74, in map
    tile = layer.render(tile_request, use_profiles=tile_request.use_profiles, coverage=limit_to)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/service/tile.py", line 265, in render
    tile = self.tile_manager.load_tile_coord(tile_coord, with_metadata=True)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 105, in load_tile_coord
    created_tiles = creator.create_tiles([tile])
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 227, in create_tiles
    created_tiles = self._create_meta_tiles(meta_tiles)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 300, in _create_meta_tiles
    created_tiles.extend(self._create_meta_tile(meta_tile))
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 309, in _create_meta_tile
    meta_tile_image = self._query_sources(query)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 274, in _query_sources
    return self.sources[0].get_map(query)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/source/wms.py", line 62, in get_map
    resp = self._get_map(query)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/source/wms.py", line 81, in _get_map
    return self._get_transformed(query, format)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/source/wms.py", line 124, in _get_transformed
    query.size, dst_bbox, self.image_opts)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/image/transform.py", line 91, in transform
    result = self._transform(src_img, src_bbox, dst_size, dst_bbox, image_opts)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/image/transform.py", line 156, in _transform
    image_filter[image_opts.resampling])
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1629, in transform
    im.__transformer(box, self, QUAD, quad, resample, fill)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1674, in __transformer
    image.load()
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 212, in load
    s = read(self.decodermaxblock)
  File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 401, in load_read
    cid, pos, len = self.png.read()
  File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 93, in read
    len, cid = self.fp.get("!I4s")
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageSupport2.py", line 105, in get
    return self.read(struct.calcsize(fmt)).unpack(fmt)
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageSupport2.py", line 76, in unpack
    raise ValueError(v)
ValueError: unpack requires a string argument of length 8
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/wsgiapp.py", line 166, in __call__
    resp = self.handlers[handler_name].handle(req)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/service/base.py", line 30, in handle
    return handler(parsed_req)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/service/tile.py", line 74, in map
    tile = layer.render(tile_request, use_profiles=tile_request.use_profiles, coverage=limit_to)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/service/tile.py", line 265, in render
    tile = self.tile_manager.load_tile_coord(tile_coord, with_metadata=True)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 105, in load_tile_coord
    created_tiles = creator.create_tiles([tile])
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 227, in create_tiles
    created_tiles = self._create_meta_tiles(meta_tiles)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 300, in _create_meta_tiles
    created_tiles.extend(self._create_meta_tile(meta_tile))
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 309, in _create_meta_tile
    meta_tile_image = self._query_sources(query)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/cache/tile.py", line 274, in _query_sources
    return self.sources[0].get_map(query)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/source/wms.py", line 62, in get_map
    resp = self._get_map(query)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/source/wms.py", line 81, in _get_map
    return self._get_transformed(query, format)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/source/wms.py", line 124, in _get_transformed
    query.size, dst_bbox, self.image_opts)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/image/transform.py", line 91, in transform
    result = self._transform(src_img, src_bbox, dst_size, dst_bbox, image_opts)
  File "/usr/local/lib/python2.7/dist-packages/mapproxy/image/transform.py", line 156, in _transform
    image_filter[image_opts.resampling])
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1629, in transform
    im.__transformer(box, self, QUAD, quad, resample, fill)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1674, in __transformer
    image.load()
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 212, in load
    s = read(self.decodermaxblock)
  File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 401, in load_read
    cid, pos, len = self.png.read()
  File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 93, in read
    len, cid = self.fp.get("!I4s")
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageSupport2.py", line 105, in get
    return self.read(struct.calcsize(fmt)).unpack(fmt)
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageSupport2.py", line 76, in unpack
    raise ValueError(v)
ValueError: unpack requires a string argument of length 8


...but second request gets through.


This is source request for test2:
http://geoportal.cuzk.cz/WMS_ZM10_PUB/service.svc/get?styles=&format=image%2Fjpeg&height=1184&bbox=-742076.617816,-1045120.38486,-741052.456103,-1044098.3743&transparent=False&layers=GR_ZM10&service=WMS&width=1186&request=GetMap&srs=EPSG%3A5514&version=1.1.1


Results are 256 color PNG in test1 (transformed looks not very well), and 16M color PNG in test2 (looks nice).


Is there other way to force MapProxy to work always in 24 bit with PNG24 source?


Martin  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapproxy/attachments/20130331/365b769c/attachment-0001.html>


More information about the MapProxy mailing list