I found this function on PHPbuilder.net. It is supposed to colorize a JPEG
image by covering it with a transparent colored overlay. I'm trying to
implement it, but whatever color value I pass it always it always colorizes
the image in greyscale.
I'm probably passing the color values incorrectly, but I'm not sure what
kind of data the function is expecting. The page where I found the function
doesn't provide any solutions.
Any help would be extremely appreciated.
////////////////////////////////////////////////////////////////////////////
////////////////////////
Here's the function :
<?php
// function creates a layover in the specified color
// use it to output images in accordance with the basecolor
// of each issue
function imagecolorize(& $im,&$col,$pct) {
// Get the image's width
$im_w = imagesx($im);
// Get the image's height
$im_h = imagesy($im);
// Set a pixel with the color, so we can get it easily
$setpixel = imagesetpixel($ im,$im_w,0,$col );
// Get the color
$index = imagecolorat($i m,$im_w,0);
// Find the color in the index
$rgb = imagecolorsfori ndex($im,$index );
// Get the red value
$r = $rgb["red"];
// Get the green value
$g = $rgb["green"];
// Get the blue value
$b = $rgb["blue"];
// Create the layover
$layover = imagecreate($im _w,$im_h);
// Allocate the color on this image
$color = imagecoloralloc ate($layover,$r ,$g,$b);
// Fill the image with the new color (this really isn't needed)
$fill = imagefill($layo ver,0,0,$color) ;
// Merge the layover on top of the older image
$merge = imagecopymerge( $im,$layover,0, 0,0,0,$im_w,$im _h,$pct);
imagedestroy($l ayover); // Destroy the layover
return $merge;
}
?>
////////////////////////////////////////////////////////////////////////////
////////////////////////
Here's my implementation :
<?php
// split color value into rgb parts
$rgb = chunk_split('ff 0000', 2);
// convert hex values to decimal
$rgb[0] = hexdec($rgb[0]);
$rgb[1] = hexdec($rgb[1]);
$rgb[2] = hexdec($rgb[2]);
$img = imagecreatefrom jpeg('logoFM720 1081767006.jpg' );
$im = imagecolorize($ img, $rgb, 20);
imagejpeg($img) ;
?>
Thank you,
..soma 0 1335 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeff Wagner |
last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read
a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting that
Numerology program I wrote years ago in VB.
There are times I am totally stuck (for instance, I just had an idea to put the numerical values of
the alphabet and months of the year in a dictionary located in a function. Then, I can import the...
|
by: JustSomeGuy |
last post by:
I need to write an new class derived from the list class.
This class stores data in the list to the disk if an object
that is added to the list is over 1K in size.
What methods of the std stl list class must Ioverride in order for this
to work?
|
by: brian.digipimp |
last post by:
Write a program that prompts the user to input a positive integer. It
should then output a message indicating whether the number is a prime
number. (Note: An even number is prime if it is 2. An odd integer is
prime if it is not divisible by an odd integer less than or equal to
the square root of the number.) I was given this assignment in my c++
class and I'm having trouble with it. I've looked at the professors lab
solutions but I just...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
|
by: fox |
last post by:
Hi,
Lacking javascript knowledge, I just realized why my project has a bug.
I am using ASP to loop through a set of records while it creates URLs
with a querystring that has a single value pair. This URL needs to open
in a floating window if clicked. (this is for an administrator and so
opening a small floater gives them more efficient access to the data that
will be displayed). I now understand that because the ASP executes first,
that...
| |
by: |
last post by:
The problem lies here eval("document.TeeForm.amt.value(S+M)");
S and M suppose to add up and the total suppose to appear on the AMT field
but it didn't. Any help?
============================ CODE
==============================================
|
by: lcdgoncalves |
last post by:
Hi everyone
Is there a real need to use keyword static with functions, if we
simply don't declare their prototypes in .h file?
Many textbooks avoid to discuss this matter and/or discuss only the
usage of static functions. I've been programming for years and I never
felt a real need for the "static approach for functions".
I don't know if this is a trivial matter since the reserved word
|
by: Anders B |
last post by:
I want to make a program that reads the content of a LUA array save file..
More precicely a save file from a World of Warcraft plugin called
CharacterProfiler, which dumps alot of information about your characters
into that save file.
Anyhow, I want to extract a couple of lines of it and save it into a
database and I need help on figuring out a good way of reading the file.
The problem is that the file can look pretty different depending...
|
by: pereges |
last post by:
Hello I need some ideas for designing a recursive function for my ray
tracing program.
The idea behind ray tracing is to follow the electromagnetic rays from
the source, as they hit the object.The object is triangulated. The
rays can undergo multiple reflections, diffractions etc of the same
object i.e. a ray hits a surface of the object, undergoes reflection
resulting in a reflected ray which can again hit a surface, corner or
edge...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |