Page 1 of 1
[56K WARN] gd removeing color
Posted: Mon Jan 01, 2007 10:22 pm
by michael1991j
hi i am useing gd
what i am trying to do is remove color to a image like

what i am trying to do is remove all the color to this radar map were the map will not show the map but show the radar scan
i have looked at the gd manual in php.net but i could not find a function that could do this
can sombody help me
Posted: Mon Jan 01, 2007 11:45 pm
by Buddha443556
imagecolorat() and imagesetpixel()? Just ignoring the map colors. Have to loop through the entire bitmap though. That could be a problem depend on your purpose with this.
Posted: Tue Jan 02, 2007 12:15 am
by Flamie
first load your image:
Code: Select all
$img = imagecreatefromgif("path to your image");
Then select your color
Code: Select all
$color = imagecolorallocate($img, r, g, b);
Make it transparent
Code: Select all
imagecolortransparent($img, $color);
Create a new image
Code: Select all
$newimg = imagecreatetruecolor(imagesx($img), imagesy($img));
Copy the old one maintaining transparency:
Code: Select all
imagecopymerge($newimg, $img, 0, 0, 0, 0, imagex($img), imagesy($img), 100);
Destroy the old image (release memory):
Save the new image without the color you removed
Code: Select all
imagegif($newimg, "path to your image");
Posted: Tue Jan 02, 2007 10:23 am
by michael1991j
Buddha443556 wrote:imagecolorat() and imagesetpixel()? Just ignoring the map colors. Have to loop through the entire bitmap though. That could be a problem depend on your purpose with this.
let me explain what i am trying to do is use map.live.com in a flash script and the mount a weather radar i mage from the noaa on there but i want to have the radar image and not the map
is this the purpose you needed buddha
flame
that php script was good but it didnt rid of the colors in the end the script distorted the image thank you but that didnt work it ended output this

Posted: Tue Jan 02, 2007 10:41 am
by feyd
Do you have a graphic of just the map? If so you can open both images in GD and compare the pixel data only keeping the difference.

Posted: Tue Jan 02, 2007 11:12 am
by Buddha443556
Have you checked out the other image downloads from NOAA? From just a quick look, some don't seem to have maps. However, they seem to be individual radar images.
http://radar.weather.gov/jetstream/remo ... wnload.htm
Posted: Tue Jan 02, 2007 2:44 pm
by michael1991j
well this is how the radar system work i just looked at the url thanks that is a great help well there are certian radars like you said but i think they houly make mosaics of all the radar in on big one
the problem is that i can only find the mosiac with everything on it and not like the minitear radar where you can costomize what you want to see
i may email just email asking if they make a mosiac on just the radar scan
or i could go two approaches i could merge the images
through
php with gd
or
i could just use action script to get the images and then merge them on the go with flash
Re: [56K WARN] gd removeing color
Posted: Tue Jan 02, 2007 3:09 pm
by Kieran Huggins
michael1991j wrote:what i am trying to do is remove color to a image like

Seems simple enough... move to Canada!

Just look at all the snow we have up there - the whole country is white! You can't even see a single highway!
Disclaimer: I'm kidding
Posted: Tue Jan 02, 2007 4:14 pm
by michael1991j
i could move to canida but i like it hard
i found a mosiac here it is
http://www.srh.noaa.gov/ridge/Conus/Rad ... 0Ronly.gif
feyd | a MASSIVE image does not need posting. 
Posted: Tue Jan 02, 2007 4:24 pm
by mibocote
You might want to try
http://us2.php.net/manual/en/function.i ... rexact.php and
http://us2.php.net/manual/en/function.imagecolorset.php
I haven't personally tried it, but it seems like you would just use imagecolorexact to find the index in the pallete of your color and then imagecolorset to change it to the background color you want.
Posted: Tue Jan 02, 2007 4:28 pm
by Kieran Huggins
michael1991j wrote:i could move to canida but i like it hard

Posted: Tue Jan 02, 2007 9:22 pm
by michael1991j
what i meant is that i like a challange and not being a lazy cold conadian
no offence
well i have another roadblock i just find out that flash wont allow me to dymacly load gif
this sucks
so i went to trusty gd i try using this code
Code: Select all
<?php
$img = imagecreatefromgif("http://radar.weather.gov/ridge/Conus/RadarImg/northeast.gif");
$color = imagecolorallocate($img, r, g, b);
imagecolortransparent($img, $color);
$newimg = imagecreatetruecolor(imagesx($img), imagesy($img));
imagecopymerge($newimg, $img, 0, 0, 0, 0, imagex($img), imagesy($img), 100);
imagedestroy($img);
imagejpeg($newimg, "./northeast.jpeg");
?>
what i am trying to do is convert gif to jpeg or if possible bmp
this script wont work so what do i do to do convert in gd
thank you in advance
Posted: Tue Jan 02, 2007 10:10 pm
by Kieran Huggins
michael1991j wrote:no offence
none taken
