RE: [PHP] FW: Merging two images (GD PNG)

2005-12-01 Thread Albert
Jochem Maas wrote:
 the output image resource you create should be created with $xxx = 
 imagecreatetruecolor(1000,1000), you should call imagealphablending($xxx,
 true) on the output image resource after you create and before copying 
 [which you are as far as I can tell], and you should use 
 imagecopyresampled() to actually copy the image data into the final image 
 (instead of imagecopy()).

It seems that I have three problems:

1. It seems that true color images do not support transparency (even though
I'm outputting to a PNG). It does not matter which colour I set to be
transparent it always is displayed as black which hides my satellite image.

2a. Because I am now forced to use a paletted image instead of a true color
image it seems that the colours in the second image is not added to the
palette of the first image.

or

2b. The alpha blending on the image causes the actual colours in the top
image to be blended with the satellite image. Because of this the top image
are blended in with the satellite image. If I do not set imagealphablending
($im, true) then the transparency in the top image is ignored and I do not
see the satellite image.

This brings me back to the original problem:
I have a true colour satellite image in PNG format. On top of this I want to
add the data collected from data collected by my company. This is always
shapes drawn which should not be alpha blended with the satellite image.
These shapes are drawn on a transparent background. The transparent
background allows for the satellite image to show through.


Any suggestions are welcome.

Albert

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] FW: Merging two images (GD PNG)

2005-12-01 Thread Albert
Jochem Maas wrote:
 try this site:
 http://php.amnuts.com/

I had a look at the way Andy does the masking and changed my code to do a
pixel compare and only transfer the pixels to the satellite image I needed. 

This now takes quite a bit longer but at least everything is working as it
should.

Albert

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FW: Merging two images (GD PNG)

2005-12-01 Thread Jochem Maas

Albert wrote:

Jochem Maas wrote:


try this site:
http://php.amnuts.com/



I had a look at the way Andy does the masking and changed my code to do a
pixel compare and only transfer the pixels to the satellite image I needed. 


This now takes quite a bit longer but at least everything is working as it
should.


ai, its process intensive to generate good quality images, I'm gald that
Andy's masking stuff helped you out - it certainly helped me.

I figured that either you could figure it out from his examples/code or you
we're in over your head :-) either way it as a little too complex for me to
try an explain it properly! (I only just grok it myself)

anyway good to see you cracked it :-)



Albert



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Jochem Maas

imagecreatetruecolor() is probably what your after:

http://php.net/imagecreatetruecolor

Albert wrote:

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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Albert
Jochem Maas wrote:
 imagecreatetruecolor() is probably what your after:
 
 http://php.net/imagecreatetruecolor

 Albert wrote:
  Notes:
  1. When using imagecreatetruecolor the images turn black

I did try imagecreatetruecolor() but then the images turn black.

Albert

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Jochem Maas

Albert wrote:

Jochem Maas wrote:


imagecreatetruecolor() is probably what your after:

http://php.net/imagecreatetruecolor

Albert wrote:


Notes:
1. When using imagecreatetruecolor the images turn black



I did try imagecreatetruecolor() but then the images turn black.


shit missed that sorry. question is where did you use then?



Albert



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Jochem Maas

Albert wrote:

Jochem Maas wrote:


imagecreatetruecolor() is probably what your after:

http://php.net/imagecreatetruecolor

Albert wrote:


Notes:
1. When using imagecreatetruecolor the images turn black



I did try imagecreatetruecolor() but then the images turn black.


the output image resource you create should be created with $xxx = 
imagecreatetruecolor(1000,1000),
you should call imagealphablending($xxx, true) on the output image resource 
after you create and
before copying [which you are as far as I can tell], and you should use 
imagecopyresampled()
to actually copy the image data into the final image (instead of imagecopy()).

try this site:
http://php.amnuts.com/

I use a very hacked up version of his image masking class to do similar things 
to
what you want to do.



Albert



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php