# Reproducing JPG image from script to make it editable

**URL:** <https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760>\
**Category:** Coding Questions\
**Created:** [September 14, 2022, 1:45pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760 "2022-09-14T13:45:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![techmouse](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@techmouse](https://discourse.processing.org/u/techmouse)\
**Post date:** [September 14, 2022, 1:45pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/1 "2022-09-14T13:45:37Z")

</div>

Hi, I want to ask, is there a script I could use to recreate an image I have and convert to a suitable format where I can make modifications to the image ?

---

<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 14, 2022, 2:51pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/2 "2022-09-14T14:51:32Z")

</div>

Hi @techmouse,

you can do s.th like this …

Cheers  
— mnse

```auto
void setup() {
  // load a src image
  PImage src = loadImage("image.jpg");
  // create target image with the same size
  PGraphics dst = createGraphics(src.width, src.height);
  dst.beginDraw();
  dst.image(src, 0, 0); // draw src to target
  // and do some modifications (ie draw a cirle at the center
  dst.fill(255, 0, 0);
  dst.noStroke();
  dst.ellipse(dst.width/2, dst.height/2, 100, 100);
  dst.endDraw();
  // save the modified image 
  dst.save("image_out.jpg");
  exit();
}

```

---

<div class="post-metadata">

**Author:** ![techmouse](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@techmouse](https://discourse.processing.org/u/techmouse)\
**Post date:** [September 15, 2022, 3:14pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/3 "2022-09-15T15:14:44Z")

</div>

@mnse Thanks for responding. I tried this code, was something suppose to happen? A screen popped up and closed.

---

<div class="post-metadata">

**Author:** ![techmouse](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@techmouse](https://discourse.processing.org/u/techmouse)\
**Post date:** [September 15, 2022, 3:15pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/4 "2022-09-15T15:15:39Z")

</div>

I just noticed that my image has a red circle on it.

---

<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 15, 2022, 3:48pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/5 "2022-09-15T15:48:32Z")

</div>

Hi @techmouse,

The red circle is only something to demonstrate.

Don’t know what you want to apply to the image by your sentence…

> [@techmouse](#):
>
> where I can make modifications to the image ?

Instead of the circle you can nearly apply everything you want with that approach. 🙂

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![techmouse](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@techmouse](https://discourse.processing.org/u/techmouse)\
**Post date:** [September 15, 2022, 3:53pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/6 "2022-09-15T15:53:53Z")

</div>

Well I wanted a script to reproduce an image that I have, like recreating it and then being able to save it to a format where I would be modify the image in a another graphic design tool.

---

<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 15, 2022, 4:03pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/7 "2022-09-15T16:03:22Z")

</div>

Do you mean this in the sense that the program analyze the image and when there is a circle and a rectangle it writes code to reproduce this?

---

<div class="post-metadata">

**Author:** ![techmouse](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@techmouse](https://discourse.processing.org/u/techmouse)\
**Post date:** [September 15, 2022, 4:15pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/8 "2022-09-15T16:15:14Z")

</div>

Analyze and photocopy the image as exact as the original, and I would be able to save it in a format where I can use it in a graphic tool.

---

<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 15, 2022, 4:38pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/9 "2022-09-15T16:38:22Z")

</div>

Which format is it now  
and what is your target format? Png?

---

<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 15, 2022, 9:04pm UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/10 "2022-09-15T21:04:42Z")

</div>

Hello @techmouse,

The links below may help.

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)

`:)`

---

<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 16, 2022, 7:29am UTC](https://discourse.processing.org/t/reproducing-jpg-image-from-script-to-make-it-editable/38760/11 "2022-09-16T07:29:02Z")

</div>

Hi @techmouse,

> [@techmouse](#):
>
> Analyze and photocopy the image as exact as the original, and I would be able to save it in a format where I can use it in a graphic tool.

Please describe a bit clearer what _analyze_ means to you, and under which circumstances do you want to save it to another format and to which format ? The source image is jpg as suggested in you title !? Didn’t your graphic tool support jpg !?

Cheers  
— mnse
