This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Class

PImage

Name

resize()

Examples
example pic
PImage jelly = loadImage("jelly.jpg");
image(jelly, 0, 0);
jelly.resize(100, 50);
image(jelly, 0, 0);
example pic
PImage jelly = loadImage("jelly.jpg");
image(jelly, 0, 0);
jelly.resize(0, 50);
image(jelly, 0, 0);
Description Resize the image to a new width and height. To make the image scale proportionally, use 0 as the value for the wide or high parameter. For instance, to make the width of an image 150 pixels, and change the height using the same proportion, use resize(150, 0).

Even though a PGraphics is technically a PImage, it is not possible to rescale the image data found in a PGraphics. (It's simply not possible to do this consistently across renderers: technically infeasible with P3D, or what would it even do with PDF?) If you want to resize PGraphics content, first get a copy of its image data using the get() method, and call resize() on the PImage that is returned.
Syntax
pimg.resize(w, h)
Parameters
pimg PImage: any object of type PImage
w int: the resized image width
h int: the resized image height
Returnsvoid
Relatedget()
Updated on January 21, 2019 10:05:12am EST

Creative Commons License