# Is there a way to pass a PNG image with the PImage.set() command?

**URL:** <https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731>\
**Category:** Coding Questions\
**Created:** [September 13, 2022, 8:10am UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731 "2022-09-13T08:10:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michele\_rinaldi](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@michele\_rinaldi](https://discourse.processing.org/u/michele_rinaldi)\
**Post date:** [September 13, 2022, 8:10am UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731/1 "2022-09-13T08:10:57Z")

</div>

I need to copy a PNG image to a JPG image. Using the command:  
`pimg.set (x, y, img);`  
I paste the image not as a PNG but as a JPG, thus inserting the background.  
Any advice to solve this problem?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [September 13, 2022, 10:46am UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731/2 "2022-09-13T10:46:38Z")

</div>

Hi @michele_rinaldi,

based on your code snippet you’re copying a PImage to another PImage, even if you are considering it as a png or jpg. Please describe in more detail what you want to achieve.

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 13, 2022, 10:50am UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731/3 "2022-09-13T10:50:04Z")

</div>

Is the png format preserved internally or does processing convert to jpg silently?

---

<div class="post-metadata">

**Author:** ![michele\_rinaldi](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@michele\_rinaldi](https://discourse.processing.org/u/michele_rinaldi)\
**Post date:** [September 13, 2022, 11:13am UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731/4 "2022-09-13T11:13:48Z")

</div>

when I load the image I specify that it is a PNG, but in the process of copying to another image, Processing automatically makes it a JPG

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [September 13, 2022, 12:31pm UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731/5 "2022-09-13T12:31:43Z")

</div>

Hi,  
What do you mean by …

> [@michele\_rinaldi](#):
>
> Processing automatically makes it a JPG

As state before … you have two PImage objects not a png and a jpg object !?  
To help, please show your code (or parts of it which demonstrates what you are doing), tell us what happens and your expectations what should be happen …

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [September 14, 2022, 12:16am UTC](https://discourse.processing.org/t/is-there-a-way-to-pass-a-png-image-with-the-pimage-set-command/38731/6 "2022-09-14T00:16:28Z")

</div>

Hello @michele_rinaldi.

> [@michele\_rinaldi](#):
>
> Any advice to solve this problem?

The links below should give you a better understanding of what a _PImage_ is.

Tutorial:

> **[Images and Pixels](https://processing.org/tutorials/pixels/)**
>
> How to load and display images as well as access their pixels.

References:  
[https://processing.org/reference/PImage.html](https://processing.org/reference/PImage.html)

`:)`
