# PImage.resize() does not resize to specified width

**URL:** <https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217>\
**Category:** Coding Questions\
**Created:** [February 8, 2019, 3:23pm UTC](https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217 "2019-02-08T15:23:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucca](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucca/32/3139_2.png) [@Lucca](https://discourse.processing.org/u/Lucca)\
**Post date:** [February 8, 2019, 3:23pm UTC](https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217/1 "2019-02-08T15:23:01Z")

</div>

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:

 ![PNG](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5cbd263ac51aafa6c13439860ac3f80986776898.jpeg)

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:

 ![PNG](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/619a353279c05fe60d7e1fd257d90b35fb6ebf6a.jpeg)

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

```auto
int windowWidth = 1280;
int windowHeight = 720;

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

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

void setup(){}

void draw()
{
  //grey
  background(123);
  
  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);
  
  //println(mouseX);
}

```

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.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [February 8, 2019, 3:37pm UTC](https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217/2 "2019-02-08T15:37:13Z")

</div>

> [@Lucca](#):
>
> img = img.get(50, 0, img.width, img.height);

possibly should be

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

```

( not tested )

---

<div class="post-metadata">

**Author:** ![Lucca](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucca/32/3139_2.png) [@Lucca](https://discourse.processing.org/u/Lucca)\
**Post date:** [February 8, 2019, 3:45pm UTC](https://discourse.processing.org/t/pimage-resize-does-not-resize-to-specified-width/8217/3 "2019-02-08T15:45:38Z")

</div>

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