mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Add documentation to Image module
This commit is contained in:
parent
2f13422537
commit
c4daa87415
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -67,6 +67,9 @@ docs/_build/
|
||||||
\#*#
|
\#*#
|
||||||
.#*
|
.#*
|
||||||
|
|
||||||
|
#VS Code
|
||||||
|
.vscode
|
||||||
|
|
||||||
#Komodo
|
#Komodo
|
||||||
*.komodoproject
|
*.komodoproject
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,58 @@ ITU-R 709, using the D65 luminant) to the CIE XYZ color space:
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.copy
|
.. automethod:: PIL.Image.Image.copy
|
||||||
.. automethod:: PIL.Image.Image.crop
|
.. automethod:: PIL.Image.Image.crop
|
||||||
|
|
||||||
|
The following script crops the input image with the provided coordinates:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
|
||||||
|
# crop method from Image module takes four coordinates as input.
|
||||||
|
# The right can also be represented as (left+width)
|
||||||
|
# and lower can be represented as (upper+height)
|
||||||
|
(left, upper, right, lower) = (200, 20, 520, 260)
|
||||||
|
|
||||||
|
# Here the image "im" is cropped and assiged to new variable im_crop
|
||||||
|
im_crop = im.crop((left, upper, right, lower))
|
||||||
|
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.draft
|
.. automethod:: PIL.Image.Image.draft
|
||||||
.. automethod:: PIL.Image.Image.filter
|
.. automethod:: PIL.Image.Image.filter
|
||||||
|
|
||||||
|
The following script blurs the input image using a filter from ImageFilter module:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
from PIL import ImageFilter
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
|
||||||
|
# Blur the input image using the filter ImageFilter.BLUR.
|
||||||
|
im_blurred = im.filter(filter=ImageFilter.BLUR)
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.getbands
|
.. automethod:: PIL.Image.Image.getbands
|
||||||
|
|
||||||
|
The following script helps to get the bands of the input image:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
print (im.getbands()) # Returns ('R', 'G', 'B')
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.getbbox
|
.. automethod:: PIL.Image.Image.getbbox
|
||||||
|
|
||||||
|
The following script helps to get the bounding box coordinates of the input image:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
print (im.getbbox())
|
||||||
|
# Returns four coordinates in the format (left, upper, right, lower)
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.getcolors
|
.. automethod:: PIL.Image.Image.getcolors
|
||||||
.. automethod:: PIL.Image.Image.getdata
|
.. automethod:: PIL.Image.Image.getdata
|
||||||
.. automethod:: PIL.Image.Image.getextrema
|
.. automethod:: PIL.Image.Image.getextrema
|
||||||
|
@ -140,8 +188,33 @@ ITU-R 709, using the D65 luminant) to the CIE XYZ color space:
|
||||||
.. automethod:: PIL.Image.Image.putpixel
|
.. automethod:: PIL.Image.Image.putpixel
|
||||||
.. automethod:: PIL.Image.Image.quantize
|
.. automethod:: PIL.Image.Image.quantize
|
||||||
.. automethod:: PIL.Image.Image.resize
|
.. automethod:: PIL.Image.Image.resize
|
||||||
|
|
||||||
|
The following script resizes the given image from (width, height) to (width/2, height/2):
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
|
||||||
|
# Provide the target width and height of the image
|
||||||
|
(width, height) = (width//2, height//2)
|
||||||
|
im_resized = im.resize((width, height))
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.remap_palette
|
.. automethod:: PIL.Image.Image.remap_palette
|
||||||
.. automethod:: PIL.Image.Image.rotate
|
.. automethod:: PIL.Image.Image.rotate
|
||||||
|
|
||||||
|
The following script rotates the input image by `theta` degrees counter clockwise:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
|
||||||
|
# Rotate the image by 60 degrees counter clockwise.
|
||||||
|
theta = 60
|
||||||
|
# Angle is in degrees counter clockwise.
|
||||||
|
im_rotated = im.rotate(angle=theta)
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.save
|
.. automethod:: PIL.Image.Image.save
|
||||||
.. automethod:: PIL.Image.Image.seek
|
.. automethod:: PIL.Image.Image.seek
|
||||||
.. automethod:: PIL.Image.Image.show
|
.. automethod:: PIL.Image.Image.show
|
||||||
|
@ -154,6 +227,20 @@ ITU-R 709, using the D65 luminant) to the CIE XYZ color space:
|
||||||
.. automethod:: PIL.Image.Image.tostring
|
.. automethod:: PIL.Image.Image.tostring
|
||||||
.. automethod:: PIL.Image.Image.transform
|
.. automethod:: PIL.Image.Image.transform
|
||||||
.. automethod:: PIL.Image.Image.transpose
|
.. automethod:: PIL.Image.Image.transpose
|
||||||
|
|
||||||
|
The following script flips the input image by using the method "Image.FLIP_LEFT_RIGHT".
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open('cat.jpg')
|
||||||
|
|
||||||
|
# Flip the image from left to right
|
||||||
|
im_flipped = im.transpose(method=Image.FLIP_LEFT_RIGHT)
|
||||||
|
# To flip the image from top to bottom,
|
||||||
|
# use the method "Image.FLIP_TOP_BOTTOM"
|
||||||
|
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.verify
|
.. automethod:: PIL.Image.Image.verify
|
||||||
|
|
||||||
.. automethod:: PIL.Image.Image.fromstring
|
.. automethod:: PIL.Image.Image.fromstring
|
||||||
|
|
Loading…
Reference in New Issue
Block a user