# Best Practices for Resizing Images - Collage Assignment

**URL:** <https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954>\
**Category:** Teaching\
**Created:** [March 23, 2020, 9:16pm UTC](https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954 "2020-03-23T21:16:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnoble](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnoble/32/99_2.png) [@mnoble](https://discourse.processing.org/u/mnoble)\
**Post date:** [March 23, 2020, 9:16pm UTC](https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954/1 "2020-03-23T21:16:15Z")

</div>

Hello Forum,

I want to confirm that if you are making a simple, animated collage with 20+. png images in Processing and you have to resize the images (in the code) that it is better to use the:

.resize command in void setup()

Rather than adding a 4th and 5th argument to:

image(pic, 0,0,150,150); in void draw()

The reason I ask is that students find it easier to understand the second method because it feels similar to a rect() or ellipse(). Also, they like to grow and shrink their images with basic variables and this works well too.

Thanks for your tips!

Margaret

---

<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:** [March 23, 2020, 9:35pm UTC](https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954/2 "2020-03-23T21:35:48Z")

</div>

Reason is performance! Much better to **resize()** once in **setup()** rather than keep resizing via **image()** at 60 FPS all the time in **draw()**! 🏎

---

<div class="post-metadata">

**Author:** ![mnoble](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnoble/32/99_2.png) [@mnoble](https://discourse.processing.org/u/mnoble)\
**Post date:** [March 24, 2020, 3:31pm UTC](https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954/3 "2020-03-24T15:31:53Z")

</div>

Definitely “collages” 🙂

Take a look:  
[https://nobleeducator.com/interactive-self-portraits/](https://nobleeducator.com/interactive-self-portraits/)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 29, 2020, 6:05pm UTC](https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954/4 "2020-03-29T18:05:16Z")

</div>

> [@mnoble](#):
>
> Take a look:

What beautiful student work!

If they want to resize once, they should do it in `setup()`. `.resize()` each frame is a very expensive operation, and it can slow sketches down enormously.

If they want to resize dynamically and the five-argument `image()` is grinding their sketch to a halt, some options to try are:

1. use scale();
2. make the image a texture on a PShape (beginShape/endShape) and redraw the shape at different sizes
3. save a group of pre-resized images in PImage or ArrayList and select one (from smallest to largest) based on the sketch state – for example, by changing an amt from 0-1.0 and using `imgs[(int)lerp(0, imgs.length, amt)]` to get the image.

---

<div class="post-metadata">

**Author:** ![mnoble](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnoble/32/99_2.png) [@mnoble](https://discourse.processing.org/u/mnoble)\
**Post date:** [March 30, 2020, 12:26am UTC](https://discourse.processing.org/t/best-practices-for-resizing-images-collage-assignment/18954/5 "2020-03-30T00:26:25Z")

</div>

Thank you for this tips - all very helpful! Our favorite trick is to use noSmooth() when our image based projects are bogged down! That is a huge help.

Hope all is well with you and the Processing foundation team. Coding is a great escape right now!
