# Save image created via createGraphics to server

**URL:** <https://discourse.processing.org/t/save-image-created-via-creategraphics-to-server/15940>\
**Category:** Coding Questions\
**Created:** [November 29, 2019, 7:54am UTC](https://discourse.processing.org/t/save-image-created-via-creategraphics-to-server/15940 "2019-11-29T07:54:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rashuan](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rashuan](https://discourse.processing.org/u/rashuan)\
**Post date:** [November 29, 2019, 7:54am UTC](https://discourse.processing.org/t/save-image-created-via-creategraphics-to-server/15940/1 "2019-11-29T07:54:13Z")

</div>

Hello, I’ve got a simple (probably not so simple) problem - sending an image generated via createGraphics function to an e-mail. So what I thought is - use a php script on the server to send an e-mail. So far so good, but the issue is sending the image from p5.js to the server where php resides. I can’t use the toDataURL() function, since it doesn’t work with this kind of object that I get with createGraphics() function. I’ve tried passing the image as a JSONed pixels array, but it takes like 100MB of data 😃 So it’s not a good option.  
Does anyone have any solutions of sending the p5.js image data to the server?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 29, 2019, 7:59am UTC](https://discourse.processing.org/t/save-image-created-via-creategraphics-to-server/15940/2 "2019-11-29T07:59:29Z")

</div>

> [@rashuan](#):
>
> I can’t use the [**toDataURL()**](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL) function, since it doesn’t work with this kind of object that I get with [**createGraphics()**](https://p5js.org/reference/#/p5/createGraphics) function.

> **[reference | p5.js](https://p5js.org/reference/#/p5.Element/elt)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

Undocumented shortcut to a [p5.Graphics](https://p5js.org/reference/#/p5.Graphics)’s drawing context: `pg._renderer.drawingContext`
