You are here: FW: Merging two images (GD & PNG) « PHP « IT news, forums, messages
FW: Merging two images (GD & PNG)

Posted by "Albert" on 11/30/05 15:30

I have two images which I want to overlay on each other.

Image1 is a satellite image.
Image2 is contains the statistical data we collected. It has a transparent
background and should be overlaid on top of the satellite image.

Both are in PNG format.

My current code:

<?
$dataImage = imagecreate(1000, 1000);
$dIBack = imagecolorallocate($dataImage, 199, 199, 199);
imagecolortransparent($dataImage, $dIBack);
$darkGreen = imagecolorallocate($tileImage, 2, 123, 48 );
$grey = imagecolorallocate($tileImage, 118, 131, 120);
$fuchsia = imagecolorallocate($tileImage, 255, 0, 255);
$aqua = imagecolorallocate($tileImage, 113, 168, 194);
$brown = imagecolorallocate($tileImage, 177, 170, 107);
$offwhite = imagecolorallocate($tileImage, 187, 210, 193);
$black = imagecolorallocate($tileImage, 0, 0, 0 );
$blue = imagecolorallocate($tileImage, 0, 0, 255);
$red = imagecolorallocate($tileImage, 255, 0, 0 );
$yellow = imagecolorallocate($tileImage, 255, 255, 0 );

/* Code to draw data on image comes here */

$satImage = imagecreatefrompng(‘sat_image.png’);

$mergedImage = imagecreate(1000, 1000);
imagealphablending($mergedImage, true);
imagecopy($mergedImage, $satImage, 0, 0, 0, 0, 1000, 1000);
imagecopy($mergedImage, $dataImage, 0, 0, 0, 0, 1000, 1000);

imagepng($mergedImage, ‘merged_image.png’);

imagedestroy($mergedImage);
imagedestroy($satImage);
imagedestroy($dataImage);
?>
 
Notes:
1. When using imagecreatetruecolor the images turn black
2. When using imagealphablending = true or imagealphablending = false
with imagecopy the result is the same. The top image is shown but it is
almost transparent. Some images are also discoloured.
3. When using imagecopymerge to copy with a pct value of 99, and commenting
out the imagealphablending line the top image does not appear at all
4. When using imagecopymerge to copy with a pct value of 99, and
imagealphablending=true, it has the same result as 2. above.
5. When using imagecopymerge to copy with a pct value of 50, and
Imagealphablending=true, it has the same result as 2. above.

What is the effect of the pct value of imagecopymerge?

Should I be using different values for the pct value of imagecopymerge or is
there an alternative method which will do what I want to be done?

It seems to me that the palette used in the top image is not merged with the
palette used in the satellite image.

Albert

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/188 - Release Date: 2005/11/29

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация