Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Replace colors in an image

by zentara (Archbishop)
on Oct 04, 2005 at 21:04 UTC ( #497408=note: print w/ replies, xml ) Need Help??


in reply to Replace colors in an image

Imager is pretty good for that. For an example of manipulation see Tk ImageMap-color-zones. That just tints images. To replace some color, you could go thru every pixel, test for the rgb value to change, then adjust each pixel. I don't see anyway other than going thru the image pixel by pixel. Tinting is fast. Testing each pixel is slow.

Here is a snippet to get pixel rgb values with GD, and I'm sure Imager has a similar method.

#!/usr/bin/perl use GD; my $image = newFromPng GD::Image('z.png'); ($x,$y)=$image->getBounds(); $maxColors = $image->colorsTotal; $pixel=$image->getPixel(23,34); ($r,$g,$b)=$image->rgb($pixel); print "$r\t$g\t$b\n";
And check out gif colour changes

I'm not really a human, but I play one on earth. flash japh


Comment on Re: Replace colors in an image
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://497408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-31 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls