Skip to content

Commit 05dcd8c

Browse files
authored
Merge pull request #696 from hx2A/addresize
Addresize
2 parents 0e7af0c + 55bb26e commit 05dcd8c

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@@ meta
2+
name = resize()
3+
type = method
4+
pclass = PImage
5+
processing_name = resize
6+
7+
@@ signatures
8+
resize(w: int, h: int, /) -> None
9+
resize(w: int, h: int, interpolation_mode: int, /) -> None
10+
11+
@@ variables
12+
h: int - height to size image to
13+
interpolation_mode: int - interpolation method for resize operation
14+
w: int - width to size image to
15+
16+
@@ description
17+
Resize the Py5Image object to a new height and width. This will modify the Py5Image object in place, meaning that rather than returning a resized copy, it will modify your existing Py5Image object. If this isn't what you want, pair this method with [](py5image_copy), as shown in the example.
18+
19+
To make the image scale proportionally, use 0 as the value for either the `w` or `h` parameter.
20+
21+
The default resize interpolation mode is `BILINEAR`. Alternatively you can use the `interpolation_mode` parameter to interpolate using the `NEAREST_NEIGHBOR` method, which is faster but yields lower quality results. You can also use `BICUBIC` interpolation, which is the most computationally intensive but looks the best, particularly for up-scaling operations.
22+
23+
@@ example
24+
image = Py5Image_resize_0.png
25+
26+
def setup():
27+
py5.rect(10, 10, 80, 80)
28+
py5.fill(255, 0, 0)
29+
py5.rect(15, 15, 10, 60)
30+
img = py5.get_pixels()
31+
for x in [80, 60, 40]:
32+
img_copy = img.copy()
33+
img_copy.resize(x, 0, py5.BICUBIC)
34+
py5.image(img_copy, 100 - x, 100 - x)

py5_docs/Reference/api_en/valid_link_cache.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,5 +515,6 @@
515515
"https://processing.org/reference/windowX.html": false,
516516
"https://processing.org/reference/windowY.html": false,
517517
"https://processing.org/reference/year_.html": true,
518-
"https://processing.org/reference/PGraphics_is3D_.html": false
518+
"https://processing.org/reference/PGraphics_is3D_.html": false,
519+
"https://processing.org/reference/PImage_resize_.html": true
519520
}

py5_resources/data/pimage.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ init,init,,method,SKIP,
201201
save,save,,method,PYTHON,implemented in pixels.py mixin
202202
copy,copy,@_return_py5image,method,JAVA,
203203
mask,mask,,method,JAVA,
204-
resize,resize,,method,SKIP,
204+
resize,resize,,method,JAVA,
205205
get_image,getImage,,method,SKIP,
206206
get_native,getNative,,method,SKIP,
207207
native,native,,unknown,SKIP,

0 commit comments

Comments
 (0)