Page 1 of 1

Image editing Functions

Posted: Fri Oct 11, 2002 8:02 am
by ozmodiar
I have just started using the image editing functions in PHP. I installed the gd extension and it appears to be working(It displays an image). I am trying to write a script to place a an image of a pin on an image of a map.
I got this example from a book put it doesn't seem to work.

Code: Select all

<?php

Header("Content-type: image/jpeg");

$image = ImageCreateFromJPEG("map.jpg");
$icon = ImageCreateFromJPEG("pin.jpg");

$trans = ImageColorAt($icon, 0, 0);
ImageColorTransparant($icon, $trans);

$width = ImageSX($icon);
$height = ImageSY($ican);

ImageCopyResized($image, $icon, 20, 20, 0, 0, $width, $height, $width, $height);
ImageJPEG($image);

ImageDestroy($image);


?>
Can anyone tell me what is wrong with this script or suggest a way of doing it.

Thanks
Ozmodiar

Posted: Fri Oct 11, 2002 8:07 am
by twigletmac
This could be a typo from when you posted in the forum but,

Code: Select all

ImageColorTransparant
should be

Code: Select all

ImageColorTransparent
Mac

Posted: Fri Oct 11, 2002 8:16 am
by ozmodiar
I changed

Code: Select all

<?php
ImageColorTransparant
?>
to

Code: Select all

<?php
ImageColorTransparent

?>
But it is still not working. The image of the map is appearing but the pin is not appearing on top of it. It appears to be a problem with this line.

Code: Select all

<?php
ImageCopyResized($image, $icon, 20, 20, 0, 0, $width, $height, $width, $height); 

?>
Thanks
Ozmodiar

Posted: Fri Oct 11, 2002 8:18 am
by volka
you don't need the resize-version, try

Code: Select all

imagecolortransparent($icon, imagecolorat($icon, 0, 0)); 
imagecopy($image, $icon, 20, 20, 0, 0, imagesx($icon), imagesy($icon));

Code: Select all

$height = ImageSY($ican); // <- typo

Posted: Fri Oct 11, 2002 8:29 am
by ozmodiar
Thanks,

Didn't spot that typo.

Its almost working. The colours seem to be a bit messed up.

Here is the address:

http://www.iptrack.cjb.net/image.php

The pin is meant to be black but it is coming up a strange colour.

Thanks,

Ozmodiar