# ImageData scaling/size issue

**URL:** https://discourse.processing.org/t/imagedata-scaling-size-issue/39314
**Category:** Coding Questions
**Created:** [October 17, 2022, 9:35am UTC](https://discourse.processing.org/t/imagedata-scaling-size-issue/39314 "2022-10-17T09:35:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Pieter](https://discourse.processing.org/u/Pieter)
#### Post date: [October 17, 2022, 9:35am UTC](https://discourse.processing.org/t/imagedata-scaling-size-issue/39314/1 "2022-10-17T09:35:43Z")

</div>

I’m trying to make a simple pixel drawing utility, this is easy enough to emulate using `rect()` calls, but I want to edit the pixel data directly. The problem seems to be that for some reason my calls to `drawingContext.putImageData` only blit the image at half the size of the canvas. Is it possible some scaling is involved behind the scenes?

The image and sketch below illustrates the problem. I’m trying to draw yellow pixels where the mouse is held down. It seems to work but the image gets drawn at half the canvas size.

![canvas](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/7/37faae065f148aaef6520177b09ab40ffcce784e.png)

> **[p5.js Web Editor](https://editor.p5js.org/PieterVerhoeven/sketches/cnX-VBJY7)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

---

<div class="post-metadata">

### Author: ![Pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Pieter](https://discourse.processing.org/u/Pieter)
#### Post date: [October 17, 2022, 6:24pm UTC](https://discourse.processing.org/t/imagedata-scaling-size-issue/39314/2 "2022-10-17T18:24:10Z")

</div>

Well, doing this after canvas creation works 🤷

```auto
let canvas = document.getElementsByTagName("canvas")[0];
canvas.width = WIDTH;
canvas.height = HEIGHT;

```

I saw `context._pixelDensity` is set to 2 and is used in a bunch of places, but just changing it before creating the canvas didn’t seem to fix it, I didn’t look very closely though.
