# The get() function returns the wrong image size

**URL:** <https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627>\
**Category:** Beginners\
**Created:** [December 17, 2025, 12:28pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627 "2025-12-17T12:28:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 17, 2025, 12:28pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/1 "2025-12-17T12:28:15Z")

</div>

When using get() to grab the screen, the image grabbed is always half the dimensions of the dimensions requested. Here the image being loaded is 512x512 to fit the canvas but after grabbing using new logo = get(0, 0, 512, 512) , it only gets 256x256 image?

MacBook Air, Processing 4.4.4

```auto
PImage logo, newlogo ;

void setup() {
  size(512,512) ;
  logo = loadImage(“data/myLogo_512.png”);
}

void draw() {
  background(0) ;
  if(newlogo != null) {
    image(newlogo, 0, 0);
  }
  else {
    image(logo, 0, 0, 512, 512);
  }
}

void mouseReleased() {
  newlogo = get(0, 0, 512, 512);
  newlogo.save(“data/newlogo.png”);
}

```

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [December 17, 2025, 1:56pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/2 "2025-12-17T13:56:18Z")

</div>

Two things to try but not at the same time!

1. add `pixelDensity(1);` in `setup` after `size`, or
2. change `image(logo, 0, 0, 512, 512);` to `image(logo, 0, 0, 1024, 1024);

I suspect that the first should work but the second is speculative. 😄

---

<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:** [December 17, 2025, 3:51pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/3 "2025-12-17T15:51:35Z")

</div>

Hello @shedMusic ,

See issue here:

> <https://github.com/processing/processing4/issues/1131>
>
> \### Most appropriate sub-area of Processing 4?
> 
> Core/Environment/Rendering
> 
> \### …Processing version
> 
> 4.4.3
> 
> \### Operating system
> 
> MacOS 11.7.10
> 
> \### Steps to reproduce this
> 
> 1. Run the attached script to demonstrate the behavior.
> 
> In v4.4.2, the color that get() reads is white, as expected. And set() draws around (350, 350) as expected. But in v4.4.3 (and v4.4.4) get() reads blue, and set() draws around (175, 175).
> 
> It appears that both get() and set() are operating on (x/2. y/2) instead of (x,y).
> 
> 
> \### snippet
> 
> \`\`\`processing
> 
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////// //\<\>// //\<\>// //\<\>// //\<\>//
> // Define colors
> color white = color(255);
> color black = color(0);
> color red = color(255, 0, 0);
> color blue = color(0, 0, 255);
> 
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////
> // Setup
> void setup() {
> size(400, 400);
> background(white);
> noLoop();
> }
> 
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////
> // Draw
> void draw() {
> stroke(blue);
> fill(blue);
> rect(165, 165, 20, 20);
> 
> // BUG 1: The color c is blue but it should be white.
> // It seems to be reading from (x/2, y/2) = (175, 175) instead of (350, 350).
> color c = get(350, 350);
> showColor(c); // R/G/B = 0.0 0.0 255.0 = blue
> 
> // BUG 2: This draws around (175, 175). It should draw around (350, 350).
> for (int x = 340; x \< 360; x++) {
> for (int y = 340; y \< 360; y++) {
> set(x, y, red);
> }
> }
> 
> //save("screenshot.xxx.png");
> }
> 
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////
> // Show information about a color
> void showColor(color c) {
> print("R/G/B =", red(c), green(c), blue(c) );
> if (c == white) {
> println(" = white");
> } else if (c == blue) {
> println(" = blue");
> } else {
> println("");
> }
> }
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////
> 
> \`\`\`
> 
> 
> \### Additional context
> 
> \_No response\_
> 
> \### Would you like to work on the issue?
> 
> No

`:)`

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 17, 2025, 4:46pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/4 "2025-12-17T16:46:25Z")

</div>

yes using pixelDensity(109 works (but not your other possible solution)

Many thanks 🙂

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 17, 2025, 4:48pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/5 "2025-12-17T16:48:17Z")

</div>

Many thanks for the info. Not sure it’s actually a bug from reading that, but if I can just set the pixelDensity to get round out, then that’s fine 👍

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [December 17, 2025, 4:57pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/6 "2025-12-17T16:57:13Z")

</div>

Just had another thought - instead of changing the pixel density try changing  
`image(newlogo, 0, 0);` to `image(newlogo, 0, 0, 512, 512);`

It is not a bug. Before hires monitors a pixel in a bitmap matched a pixel on the screen i.e. a pixel density of 1.

You are using a MacBook Air most probably with a retina display which has a pixel density of 2 so a screen pixel is a 2x2 pixel square in the bitmap image so when displayed the image appears to be half the size.

By specifying both the position, width and height you are telling Processing the actual display position and size to use. This gives a consistent output no matter what your pixel density.

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 17, 2025, 5:19pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/7 "2025-12-17T17:19:44Z")

</div>

Yes I tried that already … the new image becomes 1024x1024 🤯

Just setting the pixel density fixes this for me 👍

---

<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:** [December 17, 2025, 7:28pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/8 "2025-12-17T19:28:18Z")

</div>

I changed the subject to make it lower case for `get()` since it forced uppercase for the `G` as the first letter.

Wonder if there was a better way.

Hope you don’t mind.

`:)`

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 17, 2025, 7:40pm UTC](https://discourse.processing.org/t/the-get-function-returns-the-wrong-image-size/47627/9 "2025-12-17T19:40:11Z")

</div>

I don’t mind 😄

I did notice that … and should have changed it!
