[mapserver-dev] MapServer png vs pdf output

thomas bonfort thomas.bonfort at gmail.com
Thu Jun 9 13:56:05 PDT 2016

Could #3 be extended so that createImage takes the resolution (and maybe
other needed parameters) as a parameter? The resolution would be stored as
a parameter in the cairo_renderer struct and be applied where needed in the
cairo renderer. The scale-dependant resolution rendering is rather
involved, and I would not recommend fiddling with it inside drawMap.
Please create a pull-request for this so we can get a chance at seeing the
side-effects in the test suite.

On 9 June 2016 at 22:41, Tamas Szekeres <szekerest at gmail.com> wrote:

> Hi Devs,
> I've looked into the code and the problem described in the mail below
> still persists and the image being drawn by cairo/pdf and cairo/svg is
> incorrect.
> To summarize the things, the width and height passed to
> cairo_pdf_surface_create
> <http://cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-create>
>  or cairo_svg_surface_create
> <http://cairographics.org/manual/cairo-SVG-Surfaces.html#cairo-svg-surface-create> should be
> in points (1 point == 1/72.0 inch) which is not the case at the moment we
> are passing the width and heights in pixels therefore we get a different
> image when rendering the same with the cairo/png format.
> Is this considered as a bug that should be corrected in MapServer?
> Thanks,
> Tamas
> 2014-11-04 22:11 GMT+01:00 Tamas Szekeres <szekerest at gmail.com>:
>> Hi Devs,
>> We may experience a difference regarding to the (visual) image size when
>> saving the map to pdf vs png. The problem is already described in the
>> following issue:
>> Cairo SVG and PDF output larger than PNG
>> <https://github.com/mapserver/mapserver/issues/4487> which is related to
>> the pdf/svg canvas where the size is specified in points and not in pixels.
>> That means: each point has a fixed size of 1/72 inches regardless of the
>> device used.
>> Our problem here is that we pass the image size directly to
>> cairo_pdf_surface_create
>> <http://cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-create>
>> or cairo_svg_surface_create
>> <http://cairographics.org/manual/cairo-SVG-Surfaces.html#cairo-svg-surface-create> which
>> is incorrect. We should rather pass
>> 72.0 / map->resolution * map->width and 72.0 / map->resolution *
>> map->height respectively. And we should also set map->resolution to 72
>> before the image is drawn to let the symbols scale with the image size
>> correctly.
>> My question is what would be the correct handling for this in MapServer?
>> 1. Don't do anything in MapServer let the client programs (like mapscript
>> applications) to change the image size and scale.
>> 2. Apply these corrections at the beginning of msDrawMap (for the pdf/svg
>> renderers specifically) and restore the original values at the end of the
>> drawing operation.
>> 3. Apply these corrections at driver level (createImageCairo etc.)
>> For me #2 seems to be the most reasonable approach (with just a few lines
>> of code).
>> #1 would not help for the existing apps (mapserv, shp2img) which should
>> be fixed separately. And I cannot really see how #3 would work, since the
>> image size and resolution is not wired directly into the drivers
>> (createImage doesn't get the resolution for example).
>> Any ideas or alternatives?
>> Thanks,
>> Tamas
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20160609/054886c1/attachment.html>

More information about the mapserver-dev mailing list