[56K WARN] gd removeing color

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

[56K WARN] gd removeing color

Post by michael1991j »

hi i am useing gd


what i am trying to do is remove color to a image like

Image
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
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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.
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post 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):

Code: Select all

imagedestroy($img);
Save the new image without the color you removed

Code: Select all

imagegif($newimg, "path to your image");
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post 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

Image
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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. :)
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: [56K WARN] gd removeing color

Post by Kieran Huggins »

michael1991j wrote:what i am trying to do is remove color to a image like
Image
Seems simple enough... move to Canada! 8)

8O 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
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post 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


:D 8O

feyd | a MASSIVE image does not need posting. :?
User avatar
mibocote
Forum Newbie
Posts: 18
Joined: Sun Aug 20, 2006 9:51 am
Contact:

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

michael1991j wrote:i could move to canida but i like it hard
8O :oops:
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

michael1991j wrote:no offence
none taken :wink:
Post Reply