# How to change the color of a png image to different colors

**URL:** <https://discourse.processing.org/t/how-to-change-the-color-of-a-png-image-to-different-colors/34963>\
**Category:** Beginners\
**Created:** [February 3, 2022, 8:00pm UTC](https://discourse.processing.org/t/how-to-change-the-color-of-a-png-image-to-different-colors/34963 "2022-02-03T20:00:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joey1](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@joey1](https://discourse.processing.org/u/joey1)\
**Post date:** [February 3, 2022, 8:00pm UTC](https://discourse.processing.org/t/how-to-change-the-color-of-a-png-image-to-different-colors/34963/1 "2022-02-03T20:00:26Z")

</div>

I am hoping to know how to write a program that changes the pixels of an image to different colors (ideally it would loop through r,g,b for a variety of colors)

tint is not giving the desired effect I want.

say if the image is green, I would want the program to change its pixels to shades of red, blue, green, orange, brown, yellow etc. thanks!

PImage amzbox;  
PImage logo;  
PImage bckgrd;

void setup(){  
size(1000,displayHeight);

amzbox = loadImage(“amzbox.png”);  
logo = loadImage(“amznlogo.png”);  
bckgrd = loadImage(“amzbackg.png”);  
image(logo,0,-50);  
}

void draw(){  
run();  
}

void run(){  
image(bckgrd,0,-50);  
image(amznbox,0,-50);  
// tint(random(255), random(255),random(255));

}

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 4, 2022, 12:55am UTC](https://discourse.processing.org/t/how-to-change-the-color-of-a-png-image-to-different-colors/34963/2 "2022-02-04T00:55:19Z")

</div>

Hi and welcome

This may help

> [@Code to compare pixels by color](https://discourse.processing.org/t/code-to-compare-pixels-by-color/34764/4):
>
> It’s fun to do this, so give it a try. Is this homework? It’s easy when you copy the examples in the reference for said commands

[https://funprogramming.org/90-Change-pixel-hue-saturation-and-brightness.html](https://funprogramming.org/90-Change-pixel-hue-saturation-and-brightness.html)

[https://funprogramming.org/89-Create-your-own-photo-filters.html](https://funprogramming.org/89-Create-your-own-photo-filters.html)

[https://funprogramming.org/88-Change-pixels-using-the-pixels-array.html](https://funprogramming.org/88-Change-pixels-using-the-pixels-array.html)

[https://funprogramming.org/81-How-to-read-the-color-of-a-pixel.html](https://funprogramming.org/81-How-to-read-the-color-of-a-pixel.html)

---

<div class="post-metadata">

**Author:** ![PhoenixStormJr](https://avatars.discourse-cdn.com/v4/letter/p/43a26b/32.png) [@PhoenixStormJr](https://discourse.processing.org/u/PhoenixStormJr)\
**Post date:** [February 5, 2022, 4:59am UTC](https://discourse.processing.org/t/how-to-change-the-color-of-a-png-image-to-different-colors/34963/3 "2022-02-05T04:59:13Z")

</div>

Instead of PImage how about you use PGraphics? This allows you to write specific points to specific areas. Example

```auto
PGraphics img;

int red = 0;
int blue = 0;
int green = 0;

void setup(){
img = new PGraphics(100,100);
img.beginDraw();
img.fill(color(255,0,0));
img.stroke(color(255,0,0));
img.point(0,0);
img.endDraw();

image(img,0,0);

//you get the color of a point on screen by

round(red(get(0,0)));
}

```

I hope this helps!
