[Mapserver-users] saveImage error

WILHITE JASON W jwwilhit at srpnet.com
Tue Jan 6 15:05:27 PST 2004


I keep getting the following error when I try and run a very simple perl script using mapserver.  The following is the debug statements along with the error message.


	Hello Starting test!
		DEBUG::::  Prep returned mapscript::imageObj=HASH(0x8457140)
		DEBUG::::  Draw returned mapscript::imageObj=HASH(0x8457140)
		DEBUG::::  ./rawMSTest.png, , 1
	Can't call method "saveImage" on an undefined value at rawMSTest.pl line 129.


Here is the code snippet in question.

	#!/usr/sbin/perl

	use GD;
	use CGI;
	use POSIX;

	use strict;
	use mapscript;
	use Getopt::Long;

	#
	#=================================== MAIN ===================================
	#
	print "\nHello Starting test!\n";

	my $mapFileName = "./simpleGauge.map";
	my $pngFileName = "./rawMSTest.png";
	my $showPNG = 0;
	my ( $xMin, $xMax, $yMin, $yMax ) = (-112.39, -111.39, 33.20, 33.62);

	my $bgMap = new mapscript::mapObj( $mapFileName );
	$bgMap->{width} = 600;  
	$bgMap->{height} = 600;

	my $imgPrep = $bgMap->prepareImage();
	print "\tDEBUG::::  Prep returned $imgPrep\n";

	my $imageObj = $bgMap->draw();
	print "\tDEBUG::::  Draw returned $imgPrep\n";

	`rm -f $pngFileName`;
	print "\tDEBUG::::  $pngFileName, $mapscript::MS_PNG, $bgMap->{transparent}\n";

	my $image_url = $imageObj->saveImage( $pngFileName,  $mapscript::MS_PNG, $bgMap->{transparent}, 1, 95 ); <------Line where it is dying
	print "\tDEBUG::::  Save returned $image_url\n";

	if ($showPNG) {
		print "\nee'ing image file $pngFileName\n";
		`ee $pngFileName`;
	}


	print "\nAll done!\n";

	#===========================================================================


Am I missing something incredibly obvious?  This worked on Mapserver 3.6.4 but when I upgrade to mapserver 4.0.1 it blows up.
Any ideas?

Thanks,
-Jason





More information about the MapServer-users mailing list