ImageType.
Example:
UDFs
alpha_composite() udf
Alpha composite im2 over im1.
Signature:
im1(Image): The first image. Must have mode RGBA or LA.im2(Image): The second image. Must have the same mode and size as the first image.
- Image: An
~PIL.Image.Imageobject.
b64_encode() udf
Convert image to a base64-encoded string.
Signature:
img(Image): imageimage_format(String): image format supported by PIL
blend() udf
Creates a new image by interpolating between two input images, using
a constant alpha::
out = image1 * (1.0 - alpha) + image2 * alpha
Signature:
im1(Image): The first image.im2(Image): The second image. Must have the same mode and size as the first image.alpha(Float): The interpolation alpha factor. If alpha is 0.0, a copy of the first image is returned. If alpha is 1.0, a copy of the second image is returned. There are no restrictions on the alpha value. If necessary, the result is clipped to fit into the allowed output range.
- Image: An
~PIL.Image.Imageobject.
composite() udf
Create composite image by blending images using a transparency mask.
Signature:
image1(Image): The first image.image2(Image): The second image. Must have the same mode and size as the first image.mask(Image): A mask image. This image can have mode “1”, “L”, or “RGBA”, and must have the same size as the other two images.
convert() udf
Convert the image to a different mode.
Equivalent to PIL.Image.Image.convert().
Signature:
mode(String): The mode to convert to. See the Pillow documentation for a list of supported modes.
crop() udf
Returns a rectangular region from this image. The box is a
4-tuple defining the left, upper, right, and lower pixel coordinate. See :ref:coordinate-system.
Note: Prior to Pillow 3.4.0, this was a lazy operation.
Signature:
box(Json): The crop rectangle, as a (left, upper, right, lower)-tuple.
- Image: An
~PIL.Image.Imageobject.
effect_spread() udf
Randomly spread pixels in an image.
Signature:
distance(Int): Distance to spread pixels.
entropy() udf
Calculates and returns the entropy for the image.
A bilevel image (mode “1”) is treated as a grayscale (“L”) image by this method.
If a mask is provided, the method employs the histogram for those parts of the image where the mask image is non-zero. The mask image must have the same size as the image, and be either a bi-level image (mode “1”) or a grayscale image (“L”).
Signature:
mask(Optional[Image]): An optional mask.extrema(Optional[Json]): An optional tuple of manually-specified extrema.
- Float: A float value representing the image entropy
get_metadata() udf
Return metadata for the image.
Signature:
getbands() udf
Returns a tuple containing the name of each band in this image.
For example, getbands on an RGB image returns (“R”, “G”, “B”).
Signature:
- Json: A tuple containing band names.
getbbox() udf
Calculates the bounding box of the non-zero regions in the
image.
Signature:
alpha_only(Bool): Optional flag, defaulting toTrue. IfTrueand the image has an alpha channel, trim transparent pixels. Otherwise, trim pixels when all channels are zero. Keyword-only argument.
- Json: The bounding box is returned as a 4-tuple defining the left, upper, right, and lower pixel coordinate. See :ref:
coordinate-system. If the image is completely empty, this method returns None.
getchannel() udf
Returns an image containing a single channel of the source image.
Signature:
channel(Int): What channel to return. Could be index (0 for “R” channel of “RGB”) or channel name (“A” for alpha channel of “RGBA”).
- Image: An image in “L” mode. .. versionadded:: 4.3.0
getcolors() udf
Returns a list of colors used in this image.
The colors will be in the image’s mode. For example, an RGB image will return a tuple of (red, green, blue) color values, and a P image will return the index of the color in the palette.
Signature:
maxcolors(Int): Maximum number of colors. If this number is exceeded, this method returns None. The default limit is 256 colors.
- Json: An unsorted list of (count, pixel) values.
getextrema() udf
Gets the minimum and maximum pixel values for each band in
the image.
Signature:
- Json: For a single-band image, a 2-tuple containing the minimum and maximum pixel value. For a multi-band image, a tuple containing one 2-tuple for each band.
getpalette() udf
Returns the image palette as a list.
Signature:
rawmode(Any): The mode in which to return the palette.Nonewill return the palette in its current mode. .. versionadded:: 9.1.0
- Json: A list of color values [r, g, b, …], or None if the image has no palette.
getpixel() udf
Return the pixel value at the given position. The position xy is a tuple containing the x and y coordinates.
Equivalent to PIL.Image.Image.getpixel()
Signature:
xy(Json): The coordinates, given as (x, y).
getprojection() udf
Get projection to x and y axes
Signature:
- Json: Two sequences, indicating where there are non-zero pixels along the X-axis and the Y-axis, respectively.
height() udf
Signature:
histogram() udf
Returns a histogram for the image. The histogram is returned as a
list of pixel counts, one for each pixel value in the source image. Counts are grouped into 256 bins for each band, even if the image has more than 8 bits per band. If the image has more than one band, the histograms for all bands are concatenated (for example, the histogram for an “RGB” image contains 768 values).
A bilevel image (mode “1”) is treated as a grayscale (“L”) image by this method.
If a mask is provided, the method returns a histogram for those parts of the image where the mask image is non-zero. The mask image must have the same size as the image, and be either a bi-level image (mode “1”) or a grayscale image (“L”).
Signature:
mask(Optional[Image]): An optional mask.extrema(Optional[Json]): An optional tuple of manually-specified extrema.
- Json: A list containing pixel counts.
mode() udf
Signature:
point() udf
Map image pixels through a lookup table.
Equivalent to PIL.Image.Image.point()
Signature:
lut(Json): A lookup table.
quantize() udf
Convert the image to ‘P’ mode with the specified number
of colors.
Signature:
colors(Int): The desired number of colors, <= 256method(Optional[Int]):Quantize.MEDIANCUT(median cut),Quantize.MAXCOVERAGE(maximum coverage),Quantize.FASTOCTREE(fast octree),Quantize.LIBIMAGEQUANT(libimagequant; check support usingPIL.features.check_featurewithfeature="libimagequant"). By default,Quantize.MEDIANCUTwill be used. The exception to this is RGBA images.Quantize.MEDIANCUTandQuantize.MAXCOVERAGEdo not support RGBA images, soQuantize.FASTOCTREEis used by default instead.kmeans(Int): Integer greater than or equal to zero.palette(Optional[Int]): Quantize to the palette of givenPIL.Image.Image.dither(Int): Dithering method, used when converting from mode “RGB” to “P” or from “RGB” or “L” to “1”. Available methods areDither.NONEorDither.FLOYDSTEINBERG(default).
- Image: A new image
reduce() udf
Returns a copy of the image reduced factor times.
If the size of the image is not dividable by factor, the resulting size will be rounded up.
Signature:
factor(Int): A greater than 0 integer or tuple of two integers for width and height separately.box(Optional[Json]): An optional 4-tuple of ints providing the source image region to be reduced. The values must be within(0, 0, width, height)rectangle. If omitted orNone, the entire source is used.
resize() udf
Return a resized copy of the image. The size parameter is a tuple containing the width and height of the new image.
Equivalent to PIL.Image.Image.resize()
Signature:
rotate() udf
Return a copy of the image rotated by the given angle.
Equivalent to PIL.Image.Image.rotate()
Signature:
angle(Int): The angle to rotate the image, in degrees. Positive angles are counter-clockwise.
transpose() udf
Transpose image (flip or rotate in 90 degree steps)
Signature:
method(Int): One of :pyTranspose.FLIP_LEFT_RIGHT, :pyTranspose.FLIP_TOP_BOTTOM, :pyTranspose.ROTATE_90, :pyTranspose.ROTATE_180, :pyTranspose.ROTATE_270, :pyTranspose.TRANSPOSEor :pyTranspose.TRANSVERSE.
- Image: Returns a flipped or rotated copy of this image.