Transform Pixel Color to Yellow Depending on Luminance Formula

satshop

New Member
Ok, so I have an image which has a black background and a text (text can be any color and can be transparent aswell). I need to transform the background to yellow and the text to black.I need to do this in php and I will be using GD.I've already managed to do this if the text is transparent:\[code\]<?php $im = imagecreatefrompng("./ventures-thumb.png");$width = imagesx($im);$height = imagesy($im);$new = imagecreate($width, $height);imagecopy($new, $im, 0, 0, 0, 0, $width, $height);imagecolorset($new, imagecolorexact($new, 0, 0, 0), 255, 255, 0);for($i = 1; $i <= 127; $i++) { imagecolorset($new, imagecolorexactalpha($new, 0, 0, 0, $i), 255, 255, 0, $i);}$im = imagecreatefrompng("./black.png"); // Image with black background. Still needs to be worked here.imagecopy($im, $new, 0, 0, 0, 0, $width, $height);?>\[/code\]Now I need to do so if the alpha of the entry image is set to 0 (not transparent), any color which is not black (0,0,0) must transform with a formula depending on the luminance, which I have no idea how to get that formula, to a yellow pixel.All I know the formula of luminance: \[code\]L = (0.2126*R) + (0.7152*G) + (0.0722*B)\[/code\]The yellow I need RGB values are: 255 255 0
 
Top