# Resize Image question

**URL:** <https://discourse.processing.org/t/resize-image-question/32327>\
**Category:** Beginners\
**Created:** [September 20, 2021, 6:19am UTC](https://discourse.processing.org/t/resize-image-question/32327 "2021-09-20T06:19:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)\
**Post date:** [September 20, 2021, 6:19am UTC](https://discourse.processing.org/t/resize-image-question/32327/1 "2021-09-20T06:19:50Z")

</div>

Hi, I’m using the resize() function to resize my P5 image and want to loop through all the resized pixels, sample them and draw a circle with the color values to basically create a dot pattern style image.

It seems like the resize function isn’t working in the way I need to… Is there a different way to resize the image or am I just using the function incorrectly?

Thanks

Phil

```auto
let img;
let sizeSlider;
var dotSize;
var space;
var c;

function setup() {
  createCanvas(1024, 768);

  noStroke();

  colorMode(RGB);
  ellipseMode(CORNER);
  img = loadImage("will.jpg");
  img.resize(1024,0);
  sizeSlider = createSlider(4, 20, 6);
  sizeSlider.position(10, 10);
  sizeSlider.style('width', '200');
}

function draw() {
  background(255);
  dotSize = sizeSlider.value();
  space = dotSize /2;

  for (var x = 1; x < img.width; x = x + (dotSize+space)) {
    for (var y = 1; y < img.height; y = y + (dotSize+space)) {
      c = img.get(x, y);
      fill(c);
      circle(x, y, dotSize);
    } // end for y
  } // end for x
}

```

---

<div class="post-metadata">

**Author:** ![philipplehmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/philipplehmann/32/4111_2.png) [@philipplehmann](https://discourse.processing.org/u/philipplehmann)\
**Post date:** [September 20, 2021, 3:01pm UTC](https://discourse.processing.org/t/resize-image-question/32327/2 "2021-09-20T15:01:09Z")

</div>

Load the image in preload first  
[https://editor.p5js.org/zuvala/sketches/4QqPRO8TD](https://editor.p5js.org/zuvala/sketches/4QqPRO8TD)

```auto
function preload() {
  img = loadImage('https://picsum.photos/800/800'); // Load the image
}

```

---

<div class="post-metadata">

**Author:** ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)\
**Post date:** [September 20, 2021, 6:46pm UTC](https://discourse.processing.org/t/resize-image-question/32327/3 "2021-09-20T18:46:33Z")

</div>

@philipplehmann that worked perfectly.

Thanks

Phil
