From d1e68591ed8bf2ec32822dd2cd1d1c24bce55620 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 14:42:21 -0400 Subject: [PATCH 01/10] add resize method to Py5Image --- py5_docs/Reference/api_en/Py5Image_resize.txt | 17 +++++++++++++++++ py5_resources/data/pimage.csv | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 py5_docs/Reference/api_en/Py5Image_resize.txt diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt new file mode 100644 index 00000000..4f0ee38c --- /dev/null +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -0,0 +1,17 @@ +@@ meta +name = resize() +type = method +pclass = PImage +processing_name = resize # **REMOVE IF NOT A PART OF PROCESSING** + +@@ signatures +resize(w: int, h: int, /) -> None +resize(w: int, h: int, interpolation_mode: int, /) -> None + +@@ variables +h: int - missing variable description +interpolation_mode: int - missing variable description +w: int - missing variable description + +@@ description +The documentation for this field or method has not yet been written. If you know what it does, please help out with a pull request to the relevant file in https://github.com/py5coding/py5generator/tree/master/py5_docs/Reference/api_en/. diff --git a/py5_resources/data/pimage.csv b/py5_resources/data/pimage.csv index 2a05402c..077e043d 100644 --- a/py5_resources/data/pimage.csv +++ b/py5_resources/data/pimage.csv @@ -201,7 +201,7 @@ init,init,,method,SKIP, save,save,,method,PYTHON,implemented in pixels.py mixin copy,copy,@_return_py5image,method,JAVA, mask,mask,,method,JAVA, -resize,resize,,method,SKIP, +resize,resize,,method,JAVA, get_image,getImage,,method,SKIP, get_native,getNative,,method,SKIP, native,native,,unknown,SKIP, From 8d628df59550a84e88cf7f7d2427ec3e73fbf1d2 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 14:45:16 -0400 Subject: [PATCH 02/10] remove comment --- py5_docs/Reference/api_en/Py5Image_resize.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 4f0ee38c..5fb8dc1b 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -2,7 +2,7 @@ name = resize() type = method pclass = PImage -processing_name = resize # **REMOVE IF NOT A PART OF PROCESSING** +processing_name = resize @@ signatures resize(w: int, h: int, /) -> None From 72eead95e7e8bcf8368f64b3d5d2ef37db5400e4 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 14:46:07 -0400 Subject: [PATCH 03/10] add var descriptions --- py5_docs/Reference/api_en/Py5Image_resize.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 5fb8dc1b..300aa4f9 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -9,9 +9,9 @@ resize(w: int, h: int, /) -> None resize(w: int, h: int, interpolation_mode: int, /) -> None @@ variables -h: int - missing variable description -interpolation_mode: int - missing variable description -w: int - missing variable description +h: int - height to size image to +interpolation_mode: int - interpolation method for resize operation +w: int - width to size image to @@ description The documentation for this field or method has not yet been written. If you know what it does, please help out with a pull request to the relevant file in https://github.com/py5coding/py5generator/tree/master/py5_docs/Reference/api_en/. From e669a28e620a74cc39b11c56169c31a3820822a0 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 15:49:50 -0400 Subject: [PATCH 04/10] add resize example --- py5_docs/Reference/api_en/Py5Image_resize.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 300aa4f9..c1538eb3 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -15,3 +15,15 @@ w: int - width to size image to @@ description The documentation for this field or method has not yet been written. If you know what it does, please help out with a pull request to the relevant file in https://github.com/py5coding/py5generator/tree/master/py5_docs/Reference/api_en/. + +@@ example +image = Py5Image_resize_0.png + +def setup(): + py5.rect(10, 10, 80, 80) + py5.fill(255, 0, 0) + py5.rect(15, 15, 10, 60) + img = py5.get_pixels() + for x in [80, 60, 40]: + img.resize(x, x, py5.BICUBIC) + py5.image(img, 100 - x, 100 - x) From aea0c54ee7661b03ef975c9514ac6758063c51c3 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 16:02:18 -0400 Subject: [PATCH 05/10] add description --- py5_docs/Reference/api_en/Py5Image_resize.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index c1538eb3..42520df9 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -14,7 +14,9 @@ interpolation_mode: int - interpolation method for resize operation w: int - width to size image to @@ description -The documentation for this field or method has not yet been written. If you know what it does, please help out with a pull request to the relevant file in https://github.com/py5coding/py5generator/tree/master/py5_docs/Reference/api_en/. +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. + +The default resize interpolation mode is `NEAREST_NEIGHBOR`. This mode is fastest but yields the lowest quality results, particularly for upscaling. Other options are `BILINEAR` and `BICUBIC`, both of which provide higher quality results. @@ example image = Py5Image_resize_0.png @@ -25,5 +27,6 @@ def setup(): py5.rect(15, 15, 10, 60) img = py5.get_pixels() for x in [80, 60, 40]: - img.resize(x, x, py5.BICUBIC) - py5.image(img, 100 - x, 100 - x) + img_copy = img.copy() + img_copy.resize(x, x, py5.BICUBIC) + py5.image(img_copy, 100 - x, 100 - x) From ba3398dad69e062d23f1703c6aa9d9da1383cbbf Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 16:02:33 -0400 Subject: [PATCH 06/10] update link cache --- py5_docs/Reference/api_en/valid_link_cache.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py5_docs/Reference/api_en/valid_link_cache.json b/py5_docs/Reference/api_en/valid_link_cache.json index 75975fe1..595f4722 100644 --- a/py5_docs/Reference/api_en/valid_link_cache.json +++ b/py5_docs/Reference/api_en/valid_link_cache.json @@ -515,5 +515,6 @@ "https://processing.org/reference/windowX.html": false, "https://processing.org/reference/windowY.html": false, "https://processing.org/reference/year_.html": true, - "https://processing.org/reference/PGraphics_is3D_.html": false + "https://processing.org/reference/PGraphics_is3D_.html": false, + "https://processing.org/reference/PImage_resize_.html": true } \ No newline at end of file From 8e77e72e1b4748ffcf77a5f94eec62c522ed0113 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 16:11:42 -0400 Subject: [PATCH 07/10] improve description --- py5_docs/Reference/api_en/Py5Image_resize.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 42520df9..38211fd7 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -16,7 +16,7 @@ w: int - width to size image to @@ description 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. -The default resize interpolation mode is `NEAREST_NEIGHBOR`. This mode is fastest but yields the lowest quality results, particularly for upscaling. Other options are `BILINEAR` and `BICUBIC`, both of which provide higher quality results. +The default resize interpolation mode is `NEAREST_NEIGHBOR`. This mode is fastest but yields the lowest quality results, particularly for upscaling. Other options are `BILINEAR` and `BICUBIC`, both of which are slower but the resized images look better. @@ example image = Py5Image_resize_0.png From 98cbc404a39adb4d236d7b343290ac3b0f549c67 Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 16:15:28 -0400 Subject: [PATCH 08/10] fix truthiness of description --- py5_docs/Reference/api_en/Py5Image_resize.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 38211fd7..206eef81 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -16,7 +16,7 @@ w: int - width to size image to @@ description 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. -The default resize interpolation mode is `NEAREST_NEIGHBOR`. This mode is fastest but yields the lowest quality results, particularly for upscaling. Other options are `BILINEAR` and `BICUBIC`, both of which are slower but the resized images look better. +The default resize interpolation mode is `BILINEAR`. Alternatively you can interpolate using the `NEAREST_NEIGHBOR` method, which is faster but yields the lowest quality results. You can also use `BICUBIC` interpolation, which is the most computationally intensive but looks the best, particularly for up-scaling operations. @@ example image = Py5Image_resize_0.png From f883301cb451086ca9bf72f2d836f1297fd045de Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Sat, 23 Aug 2025 16:26:29 -0400 Subject: [PATCH 09/10] add info about 0 --- py5_docs/Reference/api_en/Py5Image_resize.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 206eef81..189f640b 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -16,6 +16,8 @@ w: int - width to size image to @@ description 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. +To make the image scale proportionally, use 0 as the value for either the `w` or `h` parameter. + The default resize interpolation mode is `BILINEAR`. Alternatively you can interpolate using the `NEAREST_NEIGHBOR` method, which is faster but yields the lowest quality results. You can also use `BICUBIC` interpolation, which is the most computationally intensive but looks the best, particularly for up-scaling operations. @@ example @@ -28,5 +30,5 @@ def setup(): img = py5.get_pixels() for x in [80, 60, 40]: img_copy = img.copy() - img_copy.resize(x, x, py5.BICUBIC) + img_copy.resize(x, 0, py5.BICUBIC) py5.image(img_copy, 100 - x, 100 - x) From 55bb26e200dcecedde4eab5e77ea6fcb6524dd8b Mon Sep 17 00:00:00 2001 From: Jim Schmitz Date: Mon, 25 Aug 2025 00:37:17 -0400 Subject: [PATCH 10/10] improve description --- py5_docs/Reference/api_en/Py5Image_resize.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_docs/Reference/api_en/Py5Image_resize.txt b/py5_docs/Reference/api_en/Py5Image_resize.txt index 189f640b..a0c38e09 100644 --- a/py5_docs/Reference/api_en/Py5Image_resize.txt +++ b/py5_docs/Reference/api_en/Py5Image_resize.txt @@ -18,7 +18,7 @@ Resize the Py5Image object to a new height and width. This will modify the Py5Im To make the image scale proportionally, use 0 as the value for either the `w` or `h` parameter. -The default resize interpolation mode is `BILINEAR`. Alternatively you can interpolate using the `NEAREST_NEIGHBOR` method, which is faster but yields the lowest quality results. You can also use `BICUBIC` interpolation, which is the most computationally intensive but looks the best, particularly for up-scaling operations. +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. @@ example image = Py5Image_resize_0.png