summaryrefslogtreecommitdiff
path: root/downImg.cgi
blob: 8eb37a16bc767067f2acf3741a257f5c4aae4cd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
my $outputDir="d:/Programe/Apache Server/htdocs/landscape/img";
##---------------------------------------------------------------------------------------
##GET THE URLS FROM THE HTTP POST REQUEST
##---------------------------------------------------------------------------------------
my $query = new CGI; 
##Get texture url
my $texture = $query->param("texture"); 
if ( !$texture ) 
	{ 
		##Problem retrieving the data
		print $query->header ( ); 
		print "no"; 
		exit; 
	} 
##Get heigthmap url
my $heightmap = $query->param("heightmap"); 
if ( !$heightmap ) 
	{ 
		##Problem retrieving the data
		print $query->header ( ); 
		print "no"; 
		exit; 
	} 
	
##---------------------------------------------------------------------------------------
##DOWNLOAD THE PICTURES TO THE OUTPUT DIR
##---------------------------------------------------------------------------------------
##Get texture
getstore($texture, "$outputDir/Texture_orig.jpg");

##Resize texture to 256x256
my $image = Image::Resize->new("$outputDir/Texture_orig.jpg");
my $gd = $image->resize(256, 256);
open(IMG,">$outputDir/Texture.jpg");
binmode IMG;
print IMG $gd->jpeg;
close IMG;

##Get heightmap
getstore($heightmap, "$outputDir/Heightmap_orig.jpg");

##Resize heightmap to 256x256
my $image = Image::Resize->new("$outputDir/Heightmap_orig.jpg");
my $gd = $image->resize(256, 256, 0);
open(IMG,">$outputDir/Heightmap.jpg");
binmode IMG;
print IMG $gd->jpeg;
close IMG;


##---------------------------------------------------------------------------------------
##PRINT SUCCESS IN HTML FORMAT
##---------------------------------------------------------------------------------------
print $query->header ( );
print "yes";
exit;