Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Apply Color To B/w Image


I have a grayscale image, (just three colors) and I want to use php to apply color to it, so it turns, say, blue. I have a ton of these greyscale images and a lot of colors, so I want to use php to do it when needed instead of doing them all by hand in photoshop. I have done some searching but I'm not even sure what to call this.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Select Image By Color
can any of u guys point me in the direction of a "select all images with
this color" script?

Like what they use @ istockphoto.com, where u get a pallette of colors
and click the desired color, after wich a selection of images with the
clicked color as dominant shows up.

Replace Color In Image With GD
I've been looking at php.net and here in the forums, but I cannot find the right function to replace a color in a image with GD. ie: I want to change the black color for white. Wich function should I use? I've been using imagecolortransparent() to transform the BLACK color to "transparent" but, I think is better to replace it to white.

GD And Changing The Color Of An Image
I'm trying to come up with a script that will change the color of a transparent png to a new color. Like #FF0000 to #0000FF. The images I'm using are solid color with a transparent background. Anyways it's not going so well. I have this script that works for palpated images but when I try to use it with an image that has alpha transparency it gets all weird on me and shows up as solid blocks of color. Code:

Replace One Color With Another In An Image?
I have the following script that replaces all red pixels on an image with a specified image tile, but I want to be able to swap the red with another hex color which I'll feed to the script. Could somebody show me how to do this? Code:

Bg Color Uploading Transaprent Image
I just have a simple upload and resize image for thumbnail code...and it works okay..my problem is.. if I'm uploading a transparent *.gif image it will create a black bg color for thumnail image..and for the original image as well..so is there any solution to this.I mean I want the image and the thumbnail still remain transparent when the uploading process done...not fill in the bg with black color..like what I have just now . PHP Code:

Font Color In Jpeg Image (nearly) Always Orange
I am trying to run a basic script that displays an existing jpeg image
and writes some text over it. Sounds simple, but I cannot seem to be
able to colour the font correctly. In the example below it should be
black but it comes out orange. In fact, even if I change the colour to
0, 0, 255 it's orange.

I've read in the PHP documentation (the user contributed notes) that
there are issues with jpeg font colouring. But I've not seen any
details. Can anyone shed light on this for me please?

The example code below is called as a function. The $image variable is
a path to the existing image file and the $ttf variable is a path to a
TrueType font. The $text variable contains a text string.

header("Content-type: image/jpeg");
$base_image = imagecreatefromjpeg($image);
$font = $ttf;
$fontcolor = imagecolorallocate($base_image, 0, 0, 0);
imagettftext($base_image, 18, 0, 10, 100, $fontcolor, $font, $text);
imagejpeg($base_image); imagedestroy($base_image);

Image Create Default Background Color
I have a script that crops and image and resizes it, but that's not the problem.

If the image is smaller than the crop area, PHP just fills it in with black.

Is there a way to make PHP fill it in with white instead of black?

Paint An Opaque Layer Of Color Over An Entire Image?
Is there code (if so, what is it?) to paint an opaque layer of color over an entire image?

Color Background Cell Color Per Row
I am trying to create a display page for my database records, where each display-row has a different color than the previous one. I think I can do that if I where able to get the rownumber of the recordset. Than for each 'even' number I asign a color, and for each 'uneven' number a different one. Code:

Using PHP To Apply A Class
I'm struggling to find out how to use php to set a class based on certain criteria. Basically, I'm using a file called navigation.html to store my primary navigation links as a list, and I'm using php's include once to access this in my pages. Obviously this means that I only need to change the navigation once to change it on all pages.

Trouble is I need to highlight the current page so that as users navigate around they know where they are. Is there some way I can use php to apply a class or id to the navigation link that points to the current page?

How To Apply Css To Php Table?
Can you please tell me how to apply css style sheet to php table?

Recursively Apply Function?
I have an array with content describing a website, the position of the page in the hierarchy is relative to it's page_parent. Top level pages have a page_parent of "0". so the following array (in the code snippet) represents a site like:

- Home
- About Us
- Services
----- Development
----- Graphics
- Contact Us

I have a function that takes $Parent and $Array and hands back only those nodes w/ the matching page_parent value. I then print out links to those pages. my question is: how can i make a Site Map by recusively applying this function? Any Ideas? Code:

How To Apply Permission Upon Upload
This code works fine on my server, but when I loaded it onto the production server, all the uploaded files have 600 permissions. How can I modify it so that upon uploading, the files have 777 permissions? Code:

How To Apply Css To A Table That Is The Only Item In A Php File Please
How to apply css to a table that is the only item in a php file please

In the page that has just the one table that is to
be included in the other 2 pages, there's some
heavy css going on, plus the text in the table
gets changed quite a lot on a daily basis.
Usually, in my program, I can highlught the text
that needs a different css applied to it and click
on the css style that applies to it, but because
the page only has the one table and nothing else,
there's no mention of the link to the styles page?

Pixel Color
I'm using PHP4.2.2 with gd on a Linux platform and am having difficulty
in solving a little problem despite going through the definitions of the
various image functions.

If you load a true-colour image from a file using...

$image=imagecreatefrompng("file.png");

....how do you then get the red, green and blue values of a pixel at $x,
$y within that image? I'm sure it's fairly simple but I can't find this
from what I've read so far.

Inverting A Color
whats the best way to invert a color(hex or dec RGB).

Background Color
I am totally baffled by what is happening in my code. I have a section
of code (shown below with two comment lines inserted). They are
essentially identical text boxes (names and variables different). Yet,
the first comes up with a white background and the second comes up with
a yellow/gold background....

Change Color
Does anyone know how I would make each row of the result a different color:
here is what I have:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<?
$connection=mysql_connect("localhost", "bla bla", "bla bla") or die
("could not connect");
mysql_select_db("yorkbia2_dbname");
$result = mysql_query("SELECT * FROM Board");
echo "<table border=0, table width=200%, bgcolor=#FFFFFF>
";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>
<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</tr>
",
$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5],
$myrow[6], $myrow[7], $myrow[8], $myrow[9], $myrow[10]);
}
echo "</table>
";
?>
</body>
</html>

How Do I Print 2>&1 In Color???
exec("chmod 0644 $fyl 2>&1");

This PHP command, as you know, will evoke an EXEC to do CHMOD on the
command line. Everything works fine, including printing the
appropriate error message piped out to STDOUT.

However, I would like the error messages in color. How do I do that
with 2>&1 within PHP or whatever?

Color In Windows CLI?
Does anyone know how to make PHP display colors in the CLI (Command
Line Interface)? I've tried almost everything including ANSI.SYS under
command.exe. I would like to find a way to do it under cmd.exe, I know
it will do colors under Linux in CLI using codes like ....

Php Color Change
I have a form that I have designed with colors. I am using php code to color
it depending upon other values.

On my pc the colors are ok. From a friends pc every field with the word
email in had a different colour. When I change the spelling of "email" to
"emial" the colours displayed on his pc revert back to the colours I have
set. We are running identical versions of windows and msie. Except mine is
the Swedish version and he has the English version.

The offending field contains a text label and an input control. If either
the text label or the name of the input control contains the word "email"
the colors are morphed. The main problem with this was that the input field
was changed to yellow text on a yellow background.

Is this because I am supplying the colors by php code or is it a problem for
all forms? What I can not fathom is why he has different colors to the ones
I have designed and why this "feature" was not displayed on my pc. We both
use std settings in MSIE.

PHP Color Function
I'm looking for a function which will take a text variable and outputs it with the php colours. Is there such functions?

Echo In A Color
I cant figure out how to echo in a color. Here is my code:

echo "<font color='#ff1200'>State / Territory Field Missing<br></font>";
the error that i receive is:

Parse error: parse error, unexpected T_IF in /home/galaxyto/public_html/phpharvest.php
I remove the font tag and the script works fine.

Color Echo?
I just started learning PHP and I am trying to read form data and then display it using echo. Here is what I am using echo $row["title"];

If I want to display it in let say red color how can I do that? I have trued
echo "<font color="#660000">$row["title"]</font>; but it gives error.

Bbcodes Color
i use the following code to replace my bbcodes:

function bb($t){
str_replace("","<img src='images/smile.gif>",$t);
return $t;
}

How do i code it so i can have colors:

ImageCreate(); Different Color Text
I am making images, that contain a name and a job title, for each employee, so i want to do it dynamically. i have created the images but i want to know how i can make different parts of the text different colors.

Php Thumbs Change Color
I have a gallery which creates thumbs from pictures that are uploaded but it changes the color.

Color The PHP Code Into HTML
I have a website source code website. I want my code in HTML page is colored as standard color syntax. Are there anytool that can help me in this problem. For ex: My code is

<?echo "something";?>

I want the code in HTML looks colorful like:

<?echo "something";?>

Ofcourse, I can change the color manually, but I have tons of code and dont want to do it by hand.

Color Coding PHP In HTML
I'm really just looking for a script, but I'm having a lot of trouble finding one. Maybe I'm using the wrong "Key" "Words", I dunno. I need a script that will color code PHP and maybe even JavaScript much like these forums do. Any ideas on where I can find such a thing?

Change Color In Php Message
I'm having trouble to change the color of a part of a message I'm
putting together in a PHP script.
The built up of the message is as follows :

$message = "Update for Request number: " . $nbr . "
" .
"Project name: " . $prjname . "
" .
$yournamestring . $yrname . "
" .
"Your email address:" . $yremail . "
" .
"Address on site:". $osaddr . "
" .
.... ;

Now I want for instance change the color of the entry "Your email
address" and if possible also of the string represented by $yremail (or
only 1 of both), if a certain condition is true (e.g this item is
changed during an update).

I tried several things, such as
"<FONT color="red">Your email address: </FONT>" .
$yremail . "
" .

but in the email received appears litteraly all what is noted, but no
text in red.

Probably I'm using the wrong quotes or on the wrong place .... Has
anyone already did something similar ?

Color Mask/Filter With GD?
Has anyone had any luck with trying to create a image mask with gd. I've gone through most of the manual and the closest thing I could get was

http://www.php.net/manual/en/functi...phablending.php

I want to put a color layer over and image that makes it look like it has a blue tint or red tint etc. The GD Manual isn't really any help either.

Sort Color Array?
i found this message:
and i want to know more about it too.
==========================================
example:
$s_Colors="0066FF;0066CC;3366CC;0033FF;003399;003366;99CCFF;3 399FF;0099FF;66
99CC;336699;006699;66CCFF;33CCFF;00CCFF;3399CC;009 9CC;003333;99CCCC;66CCCC;3
39999;669999;006666;336666;CCFFFF;99FFFF;66FFFF;33 FFFF;00FFFF;00CCCC;99FFCC;
66FFCC;33FFCC;00FFCC;33CCCC;009999;66CC99;33CC99;0 0CC99;339966;009966;006633
;66FF99;33FF99;00FF99;33CC66;00CC66;009933;99FF99; 66FF66;33FF66;00FF66;33993
3;006600;CCFFCC;99CC99;66CC66;669966;336633;003300 ;33FF33;00FF33;00FF00;00CC
00;33CC33;00CC33;66FF00;66FF33;33FF00;33CC00;33990 0;009900;CCFF99;99FF66;66C
C00;66CC33;669933;336600;99FF00;99FF33;99CC66;99CC 00;99CC33;669900;CCFF66;CC
FF00;CCFF33;CCCC99;666633;333300;CCCC66;CCCC33;999 966;999933;999900;666600;F
FFFFF;CCCCCC;999999;666666;333333;000000;43dddd;65 432b;777665;4443cc;CCCCC3;
A906B0;9CC33F;C8C8C8;688888;777752;66E554;7655FF;5 55577;D4DCE8;99AECE;3A5A8A
;9A0030;EF3F6B;FFF543;C906CF;AA2222 ";
And true a function i add random colors in the string,
$s_Colors.= ";".strtoupper($_POST['colorvalue']);

then i make one array:
$a_Colors=array_change_key_case(split(";",$s_Colors), CASE_UPPER);
when i do
sort($a_Colors);
print_r($a_Colors);

or
asort($a_Colors);
print_r($a_Colors);

Search Images By Color
is there any way to make a search tool that finds images by their color using a color palette?

Change Link Color
i'm making a search cloud page, where the latest keywords that have been searched are listed in a table it pulls this information from my database now I want to change the color of the link depending on their serach count for example

keyword > 100 counts - make the link green
keyword <100 counts make the link blue

is there a way to do this in php? also i realize that you can use css to change link colors in a page, but I don't know how to use css to specifically change only certain links, and make those certain colors.

2 Color Rows When List
how can I make a 2 color row when I list something from dbase? example:
When I listing from dbase with "while", I can't do this.

Change Text Color
I have a web page that generates font images so viewers can preview different fonts. I now want to add the feature of letting the viewer change the color of the font by selecting from a menu of colors. I have the first part of the code (GET color.....), but I do not know how to call the variables using a menu in the HTML. Code:

Change Cell Bg Color While Looping...
Hey, once i saw a really neat piece of code to be able to switch a value between to differents while looping!

right now im using something like this, but issen't there any better ways to do it?

$color = "#FFFFFF";

function bgcolor() {
if ($color == "#FFFFFF") { $color = "#666666"; } else { $color = "#FFFFFF"; }
}

for (..bla bla..) {
bgcolor();
echo $color;
}

the one i saw had a '?' and ':' in it, but donno what kind of function that would be?? any clues or solutions??

regards
Simon

Controlling Row Color With Mysql Output
I cant figure out how to control the <tr> color when mysql outputs a query. I want the rows to alternate color (e.g. white, grey, white, grey...) Any thoughts on how I can achieve this?

Multiple Rows And Alternate Color
Below I found a code to make multiple colums from the output of a DB, how
can I incorporate alternat colors to the multiple row snippet?

<?php
//set the number of columns
$columns = 2;
mysql_connect('localhost','','');
mysql_select_db('test');
$query = "SELECT stuff FROM mystuff ORDER BY stuff";
$result = mysql_query($query);
//we add this line because we need to know the number of rows
$num_rows = mysql_num_rows($result);
echo "<TABLE BORDER="0">";
//changed this to a for loop so we can use the number of rows
for($i = 0; $i < $num_rows; $i++) {
$row = mysql_fetch_array($result);
if($i % $columns == 0) {
//if there is no remainder, we want to start a new row
echo "<TR>";
}
echo "<TD>" . $row['stuff'] . "</TD>";
if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) {
//if there is a remainder of 1, end the row
//or if there is nothing left in our result set, end the row
echo "</TR>";
}
}
echo "</TABLE>";
?>

Script Altering Photos Color
I have a php script that is creating a thumb but the colors come out strange.

How Save To PNG 8-bit Single-color Transparancy Using GD2?
(PHP4.3.4, GD2) How can I save a PNG using GD2 and insure that it saves as a
palette-based (8-bit, 256-color) single-color transparancy?? Saving this
way, I could be sure that an image loaded from a transparent gif could be
saved as a png and the png would work in IE versions 5.5 and greater (IE has
bug that messes up png transparancies which use full alpha channel).

Field Changed Color On Status
i want to be able to have my Listed Feild Change a diffrent Color
Depending on if the job is Completed "green" Pending:"yellow"
Stalled:"red", So when the user Selects Pending in the dopdown and he lists the Job it will be Colored "yellow" with the words Pending:

Table Color Loop Not Working...
I wanted the the cell colors to alternate but it doesnt seem to be working...Just point me in the right direction and i will figure it out on my own, tahnks guys. PHP Code:

Change Color In The Message Of Email
I have a program which sends a message through php.. The data is collected from MY Sql database and send using mail function.. Now I want to make some words bold in the message and change color of some words... But I cannot do it through the HTML Tags.

Using Sessions To Change Background Color
I am trying to use session to store the background color throughout each page by session variables. I think the problem comes from the structure of my site. each page is accessed by ?topic=home or ?topic=tutorials It is setup as: example not actual code:

Color Loss When Creating Thumbnail
I'm used the code below running with GD. It gave me thumbnail OK with full colors; but if I change $max_width = 120; and $max_height = 100 (since I want larger thumbnail), most colors in the image will be lost. What's to do? PHP Code:

Change The Color Of An Text Anchor
Rollovers that work. I'm looking for at class that will let me change the color of an text anchor <a> when I move the mouse over an image. So far I have only been able to find some horrible Java-script examples. IE is easy enough but Netscape seems to be a pain in the a.. when it comes to rollovers.

Table Background Color Based On Value
I'm trying to make this happen on query from my database .

$h1 = 4;
$h2 = 5;

if ($h1 == 4){$color="green";}
if ($h2 == 5){$color="yellow";}

print "<table><tr>";
print "<td bgcolor=$color>$h1</td>";
print "<td bgcolor=$color>$h2</td>";
print "</tr></table>";

Changing Cell Color Based On Value?
I am writing a script for a football league I am in. You pick the NFL winners each week. Now I am working on a table, that lists the player who made selection, then have it have a "green" cell if the selection is correct, or a "red" cell if the selection is wrong. Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved