[ka-Map-users] Simply modification to allow compression settingsfor jpeg output

Delfos, Jacob Jacob.Delfos at maunsell.com
Mon May 15 19:17:14 EDT 2006


Clark,
 
Ka-Map actually supports different image formats for different layers. I
also use JPEG for the same reasons, but I use GIF to render the
shapefile layers, to keep transparency, and because GIF compresses
better than PNG 8-bit. To use the custom image format, just put
something like this in your metadata
 
METADATA
imageformat "JPEG"
# imageformat "GIF" # can use GIF
# imageformat "PNG24" # or JPEG
END
 
Be aware that for transparency with GIF to work, it must be set as the
IMAGETYPE in your mapfile (so that it is the default, and JPEG becomes
the custom format). For some reason, if IMAGETYPE is JPEG, then GIF's
become opaque, not transparent.
 
regards,
 
Jacob
 
 


________________________________

	From: ka-map-users-bounces at lists.maptools.org
[mailto:ka-map-users-bounces at lists.maptools.org] On Behalf Of Clark
Endrizzi
	Sent: 16 May 2006 01:10
	To: ka-map-users at lists.maptools.org
	Subject: [ka-Map-users] Simply modification to allow compression
settingsfor jpeg output
	
	
	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: 
	
	Config.php
	

		        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        
		            break;


	tile.php
	

		            if($szImageQuality){
		                eval("$szImageOutputFunction( \$oTile,
'".$szTileImg."', '".$szImageQuality."');"); 
		            }else{
		                eval("$szImageOutputFunction( \$oTile,
'".$szTileImg."');"); 
		            }


	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.
	
	Thanks!
	
	-- 
	Clark Endrizzi
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20060516/2e01e8e2/attachment.html


More information about the ka-Map-users mailing list