diff --git a/docs/example/imageops_contain.png b/docs/example/imageops_contain.png new file mode 100644 index 00000000000..293b0579465 Binary files /dev/null and b/docs/example/imageops_contain.png differ diff --git a/docs/example/imageops_cover.png b/docs/example/imageops_cover.png new file mode 100644 index 00000000000..929e1d87403 Binary files /dev/null and b/docs/example/imageops_cover.png differ diff --git a/docs/example/imageops_fit.png b/docs/example/imageops_fit.png new file mode 100644 index 00000000000..13a3d5e3feb Binary files /dev/null and b/docs/example/imageops_fit.png differ diff --git a/docs/example/imageops_pad.png b/docs/example/imageops_pad.png new file mode 100644 index 00000000000..69649d6e5fc Binary files /dev/null and b/docs/example/imageops_pad.png differ diff --git a/docs/reference/ImageOps.rst b/docs/reference/ImageOps.rst index ad475e7fcc4..26ca5e8a139 100644 --- a/docs/reference/ImageOps.rst +++ b/docs/reference/ImageOps.rst @@ -12,15 +12,11 @@ only work on L and RGB images. .. autofunction:: autocontrast .. autofunction:: colorize -.. autofunction:: contain -.. autofunction:: cover -.. autofunction:: pad .. autofunction:: crop .. autofunction:: scale .. autofunction:: deform .. autofunction:: equalize .. autofunction:: expand -.. autofunction:: fit .. autofunction:: flip .. autofunction:: grayscale .. autofunction:: invert @@ -28,3 +24,29 @@ only work on L and RGB images. .. autofunction:: posterize .. autofunction:: solarize .. autofunction:: exif_transpose + +Resize relative to a given size +------------------------------- + +:: + + from PIL import Image, ImageOps + size = (100, 150) + with Image.open("Tests/images/hopper.png") as im: + ImageOps.contain(im, size).save("imageops_contain.png") + ImageOps.cover(im, size).save("imageops_cover.png") + ImageOps.fit(im, size).save("imageops_fit.png") + ImageOps.pad(im, size, color="#f00").save("imageops_pad.png") + ++------+--------------------------------------------+------------------------------------------+----------------------------------------+----------------------------------------+ +| | :meth:`contain` | :meth:`cover` | :meth:`fit` | :meth:`pad` | ++======+============================================+==========================================+========================================+========================================+ +|Size | (100, 100) | (150, 150) | (150, 100) | (150, 100) | ++------+--------------------------------------------+------------------------------------------+----------------------------------------+----------------------------------------+ +|Image | .. image:: ../example/imageops_contain.png | .. image:: ../example/imageops_cover.png | .. image:: ../example/imageops_fit.png | .. image:: ../example/imageops_pad.png | ++------+------------+-------------------------------+------------------------------------------+----------------------------------------+----------------------------------------+ + +.. autofunction:: contain +.. autofunction:: cover +.. autofunction:: fit +.. autofunction:: pad