PImage.resize() does not resize to specified width

Hey fellow Processors,

I am trying to crop a PImage and then resize it to its original width.

Essentially, I am trying to get rid of the black border on the left side of the PImage:

Unfortunately, if I use PImage.get(); to crop it and then resize it to the display window’s width,
it remains at its cropped width leaving me with a border on the right side of the display window:

Here is the code, “toCrop” is a 1280x720 PNG file:

int windowWidth = 1280;
int windowHeight = 720;

PImage img = new PImage(windowWidth, windowHeight, ARGB);

void settings()
  size(windowWidth, windowHeight, P2D);

void setup(){}

void draw()
  img = loadImage("toCrop.png");
  //remove first 50 columns 
  img = img.get(50, 0, img.width, img.height);
  //resize to original dimensions
  img.resize(windowWidth, windowHeight);
  image(img, 0, 0);

My goal is to stretch the image to its original, coincidentally also the display window’s, width.

I thought at first that maybe resize only works to smaller resolutions, but I have definitely used it to blow up images before.

1 Like

possibly should be

img = img.get(50, 0, img.width-50, img.height);

( not tested )


I could have sworn that I had actually tried that before, but apparently not. It is working now, thank you!