# Processing 4 resize()

**URL:** <https://discourse.processing.org/t/processing-4-resize/25812>\
**Category:** Processing\
**Created:** [November 29, 2020, 4:41pm UTC](https://discourse.processing.org/t/processing-4-resize/25812 "2020-11-29T16:41:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)\
**Post date:** [November 29, 2020, 4:41pm UTC](https://discourse.processing.org/t/processing-4-resize/25812/1 "2020-11-29T16:41:53Z")

</div>

Hi, I’m trying to use resize() in Processing 4:

```auto
masque.resize(img.width, img.height);

```

But I’ve got this error : `RuntimeException: resize() not implemented for this PImage type`

It’s work fine with 3.5.4, there is a way to go around or it’s planned to implement ?

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 29, 2020, 11:42pm UTC](https://discourse.processing.org/t/processing-4-resize/25812/2 "2020-11-29T23:42:39Z")

</div>

Hi,

If you look into the [processing 4 GitHub repo](https://github.com/processing/processing4), you can find the source file where it throws an error :

```auto
~/Downloads/processing4   master  grep -n -R "PImage type"
core/src/processing/core/PImage.java:492: throw new RuntimeException("resize() not implemented for this PImage type");

```

Which leads to :

```auto
/**
   *
   * Resize the image to a new width and height. To make the image scale
   * proportionally, use 0 as the value for the <b>wide</b> or <b>high</b>
   * parameter. For instance, to make the width of an image 150 pixels, and
   * change the height using the same proportion, use resize(150, 0).<br />
   * <br />
   * Even though a PGraphics is technically a PImage, it is not possible to
   * rescale the image data found in a PGraphics. (It's simply not possible
   * to do this consistently across renderers: technically infeasible with
   * P3D, or what would it even do with PDF?) If you want to resize PGraphics
   * content, first get a copy of its image data using the <b>get()</b>
   * method, and call <b>resize()</b> on the PImage that is returned.
   *
   * @webref pimage:method
   * @webBrief Resize the image to a new width and height.
   * @usage web_application
   * @param w the resized image width
   * @param h the resized image height
   * @see PImage#get(int, int, int, int)
   */
  public void resize(int w, int h) { // ignore
    throw new RuntimeException("resize() not implemented for this PImage type");
  }

```

It explains clearly why you can’t resize `PGraphics`. But it’s strange because it’s in the PImage source file…

You should open an issue on GitHub maybe it’s a mistake 😉

- [https://github.com/processing/processing4/blob/master/core/src/processing/core/PImage.java](https://github.com/processing/processing4/blob/master/core/src/processing/core/PImage.java)

---

<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 30, 2020, 5:52am UTC](https://discourse.processing.org/t/processing-4-resize/25812/3 "2020-11-30T05:52:50Z")

</div>

> [@josephh](#):
>
> maybe it’s a mistake

This strongly smells like a big regression which attempts to make PImage objects bound to the current renderer like PGraphics already are. 👃

Such change would make multi-thread sketches even harder to code! 😠

---

<div class="post-metadata">

**Author:** ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)\
**Post date:** [November 30, 2020, 11:16am UTC](https://discourse.processing.org/t/processing-4-resize/25812/4 "2020-11-30T11:16:02Z")

</div>

I found a solution :

```auto
masque = createImage(img.width, img.height, ALPHA);
masque.copy(masques[m], 0, 0, masques[m].width, masques[m].height,
 0, 0, img.width, img.height);
        

```
