[OpenLayers-Dev] Poor Image Quality

Andrew Hughes azza at lisasoft.com
Tue Jul 10 23:09:34 EDT 2007


I think I can explain this, but probably can't fix it.....

I suspect your image is grainy.... PNG-8 in mapserver is (normally) 
achieved by reducing the 24bit color palette to a very simple default 
256 color palette. This means that you don't get a logical choice of 
what 256 color's you want in your palette. This also means that the true 
color of a pixel and the "best match" color in the default palette are 
;ikely to differ significantly...  hence a grainy appearance. When you 
switch to png24 you avoid this progress... but watch the size of your 
images.... my png24 256x256 tiles are ~65KB (and unusable)!

Ideally what you want to occur in the compression to 8bit is to analyze 
the 24bit images and generate a color palette that will give you best 
results.. this is known as "Color Quantization".........

see: http://en.wikipedia.org/wiki/Color_quantization

I'm sorry to say, I don't think mapserver offers this... so I can't 
offer you an easy solution... but hopefully an understanding of the 
problem if you want to chase it up further. Try the mapserver guys :)

--AH


re: png being smaller.... I've tried every trick in the book (because I 
really wanted to use png) and other than say a single flat color, or the 
most basic of image I can never get png smaller than jpeg. Map's, and in 
particular "useful" maps typically contain content, and hence multiple 
colors... consequently png is always bigger for me anyway. I wouldn't 
always recommend jpeg over png, I'd just look at whats most important to 
you, quality or size. Hope this was of some value....



Bradley Mclain wrote:
> Sorry for the triple reply but I managed to solve it by editing the 
> Mapserver/Untiled.js file to have default image type as png24.
>
> On 7/11/07, *Bradley Mclain * <bradleym06 at gmail.com 
> <mailto:bradleym06 at gmail.com>> wrote:
>
>     Little update which might help shed some light on the matter. I
>     saved that particular layer and it is a PNG format
>      not PNG24 or jpeg, so somehow OpenLayers request to Mapserver is
>     ignoring the new formats.
>
>     I did WMS URL requests to Mapserver and it returns the correct
>     formats.
>
>
>     On 7/11/07, *Bradley Mclain* < bradleym06 at gmail.com
>     <mailto:bradleym06 at gmail.com>> wrote:
>
>         For some reason this is not working for me, I changed the
>         settings in the Mapfile and defined the OUTPUTFORMAT and then
>         added the format:'image/png', to my Openlayers folder. I even
>         tried changing my mapfile to export as jpeg so as to match
>         Openayers but no luck.
>
>         Could it have something to do with that I am using the
>         MapServer.Untiled layer function instead of a WMS.Untiled layer?
>
>
>         On 7/10/07, *Andrew Hughes* <azza at lisasoft.com
>         <mailto:azza at lisasoft.com>> wrote:
>
>             Bart's correct... but just be warned.... jpeg is A LOT
>             smaller is size than png-24. There's a reason why jpeg is
>             the default in OpenLayers.
>
>             --AH
>
>
>             Bart van den Eijnden (OSGIS) wrote:
>>             OpenLayers uses jpeg by default for WMS layers, so change it in the
>>             constructor of your WMS.Untiled layer:
>>
>>             'format':'image/png', i.e.:
>>
>>             baselayer0 = new OpenLayers.Layer.WMS.Untiled
>>
>>
>>
>>             ( "Standaard",
>>                            
>>             "http://test.intranet.rijkswaterstaat.nl/services/geoservices/startkaart?"
>>
>>
>>
>>              <http://test.intranet.rijkswaterstaat.nl/services/geoservices/startkaart?>,
>>             {layers: 'startkaart', 'format':'image/png', 'transparent':'TRUE'},
>>             {'numZoomLevels': 12, 'ratio':1, isBaseLayer: true} ); 
>>
>>             Also check you have image/png mapped as a mimetype for PNG24 in your
>>
>>
>>
>>
>>             Mapserver MAP file (OUTPUTFORMAT section).
>>
>>             Best regards,
>>             Bart
>>
>>             --
>>             Bart van den Eijnden
>>             OSGIS, Open Source GIS
>>
>>
>>
>>
>>             http://www.osgis.nl
>>
>>
>>             --------- Oorspronkelijk bericht --------
>>             Van: Bradley Mclain <bradleym06 at gmail.com> <mailto:bradleym06 at gmail.com>
>>             Naar: OpenLayers ML <dev at openlayers.org> <mailto:dev at openlayers.org>
>>             Onderwerp: [OpenLayers-Dev] Poor Image Quality
>>             Datum: 10/07/07 05:07
>>
>>               
>>>             I am importing an image as an untiled Mapserver layer into OpenLayers and
>>>                 
>>             it is of extremely good quality but when it shows up in OpenLayers it&#39;s
>>             quality is terrible.The image when viewed through Mapserver is not as good
>>             as the original but it still much better than what it is showing up as in
>>
>>
>>
>>
>>             OpenLayers. I have my Mapserver image format as PNG24.
>>               
>>>             Any ideas on what might be causing this and how to fix it?CheersBrad
>>>
>>>
>>>
>>>
>>>
>>>             _______________________________________________
>>>             Dev mailing list
>>>
>>>
>>>
>>>
>>>             Dev at openlayers.org <mailto:Dev at openlayers.org>
>>>             http://openlayers.org/mailman/listinfo/dev
>>>
>>>                 
>>             _______________________________________________
>>             Dev mailing list
>>             Dev at openlayers.org <mailto:Dev at openlayers.org>
>>             http://openlayers.org/mailman/listinfo/dev
>>
>>               
>
>
>
>
>
>
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20070711/054e966d/attachment.html


More information about the Dev mailing list