[ka-Map-users] Simply modification to allow compression settings
for jpeg output
cendrizzi at gmail.com
Mon May 15 13:09:41 EDT 2006
ON our site I think I'm going to switch to Jpeg output from PNG24. I like
PNG24 more without a doubt but the Jpeg images are about 1/4 the size (I'm
using aerial imagery) so it will be a lot better bandwidth-wise.
The problem I saw with using jpeg is it uses GD's default JPEG settings
which is about 75% quality. Shape files like streets look terrible at this
quality setting so I quickly added a little bit to make it possible for the
user to define their own compression. Here is the code:
> case "JPEG":
> $GLOBALS['szMapImageFormat'] = 'JPEG'; //mapscript format name
> $GLOBALS['szImageQuality'] = '90'; //mapscript image quality,
> only applies to jpeg images
> $GLOBALS['szMapImageCreateFunction'] = "imagecreatefromjpeg";
> // appropriate GD function
> $GLOBALS['szImageExtension'] = '.jpg'; //file extension
> $GLOBALS['szImageCreateFunction'] = "imagecreatetruecolor";
> //or imagecreatetruecolor if PNG24 ...
> $GLOBALS['szImageOutputFunction'] = "imagejpeg"; //or
> imagegif, imagejpeg ...
> $GLOBALS['szImageHeader'] = 'image/jpeg'; //the content-type
> of the image
> eval("$szImageOutputFunction( \$oTile, '".$szTileImg."',
> eval("$szImageOutputFunction( \$oTile,
The code is pretty self explanatory. I don't know if this project would
consider this addition but I think it's important for users to be able to
define image quality for jpegs.
BTW, I'm using version .2 (from CVS at that time) so I'm not sure if this
has been added since.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ka-Map-users