# How to load my canvas so I can do pixel manipulation

**URL:** <https://discourse.processing.org/t/how-to-load-my-canvas-so-i-can-do-pixel-manipulation/34406>\
**Category:** Coding Questions\
**Created:** [January 1, 2022, 10:38am UTC](https://discourse.processing.org/t/how-to-load-my-canvas-so-i-can-do-pixel-manipulation/34406 "2022-01-01T10:38:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![goldorak](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@goldorak](https://discourse.processing.org/u/goldorak)\
**Post date:** [January 1, 2022, 10:38am UTC](https://discourse.processing.org/t/how-to-load-my-canvas-so-i-can-do-pixel-manipulation/34406/1 "2022-01-01T10:38:15Z")

</div>

Hi,

I’d like to play around with an existing sketch which uses:

> function preload() {  
> img = loadImage(url + str(windowWidth) + random(keywords));  
> }

Excepted that I don’t want to use an external image, I would like to work on the generated drawings from my sketch.

Here is a very simple code to illustrate what I got:

> let pg;  
> let size = 300;
> 
> function setup() {
> 
> createCanvas(size, size);  
> pg = createGraphics(size,size)  
> pg.background(random(255));  
> art();  
> noLoop();
> 
> }
> 
> function draw() {  
> image(pg,0,0, width, height);
> 
> }
> 
> function art(){
> 
> for (let i = 0; i \< 100; i++) {  
> pg.fill(random(250),random(250),random(250));  
> pg.strokeWeight(1.15);  
> pg.circle(random(size),random(size),random(100));
> 
> }  
> }

I would have assumed that adding everything into my pg object would be the equivalent of loadImage but apparently it’s not.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [January 1, 2022, 4:56pm UTC](https://discourse.processing.org/t/how-to-load-my-canvas-so-i-can-do-pixel-manipulation/34406/2 "2022-01-01T16:56:47Z")

</div>

Can you be specific about what is not working, or what you are observing when you run this code? Your code looks like it should work, but I’m not in a position to test it right now.

---

<div class="post-metadata">

**Author:** ![goldorak](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@goldorak](https://discourse.processing.org/u/goldorak)\
**Post date:** [January 1, 2022, 5:10pm UTC](https://discourse.processing.org/t/how-to-load-my-canvas-so-i-can-do-pixel-manipulation/34406/3 "2022-01-01T17:10:55Z")

</div>

Hi Paul,  
I’ve found a solution, I’m using get() to import my final canvas back into an object that I can pass later on into the post processing functions.  
My only remaining issue is the image quality.  
When I display again the content of the variable containing the result of get() I have a very poor image quality.
