Defaults to the maximum value, 256 colors. Controls the number of colors used for the palette when palette is ADAPTIVE. To use an optimized palette, use ADAPTIVE.Ĭolors=. The default is WEB, which is the standard 216-color “web palette”. The default is FLOYDSTEINBERG, which distributes errors to neighboring pixels. Same, but provides better control when converting an “RGB” image to an 8-bit palette image. To disable dithering, use the dither= option (see below). To use other thresholds, use the point method. Resulting values larger than 127 are then set to white, and the image is dithered. When converting to a bilevel image (mode “1”), the source image is first converted to black and white. When converting from a colour image to black and white, the library uses the ITU-R 601-2 luma transform: If mode is omitted, a mode is chosen so that all information in the image and the palette can be represented without a palette. When converting from a palette image, this translates pixels through the palette. For other modes, this function behaves like a corresponding call to the fromstring function.Ĭonverts an image to another mode, and returns the new image. Not all modes can share memory supported modes include “L”, “RGBX”, “RGBA”, and “CMYK”. For some modes, the image memory will share memory with the original buffer (this means that changes to the original buffer object are reflected in the image). Creates an image memory from pixel data in a string or buffer object, using the standard “raw” decoder. Note that the function is evaluated once for each possible pixel value, so you cannot use random components or other generators. If the image has more than one band, the same function is applied to each band. eval ( image, function ) ¶Īpplies the function (which should take one argument) to each pixel in the given image. The mask can have mode “1”, “L”, or “RGBA”. composite ( image1, image2, mask ) ¶Ĭreates a new image by interpolating between the given images, using the corresponding pixels from a mask image as alpha. If necessary, the result is clipped to fit into the allowed output range. There are no restrictions on the alpha value. If the alpha is 1.0, a copy of the second image is returned. If the alpha is 0.0, a copy of the first image is returned. Out = image1 * (1.0 - alpha) + image2 * alpha Both images must have the same size and mode. blend ( image1, image2, alpha ) ¶Ĭreates a new image by interpolating between the given images, using a constant alpha. In the latter case, the file object must implement read, seek, and tell methods, and be opened in binary mode. You can use either a string (representing the filename) or a file object as the file argument. If the mode argument is given, it must be “r”. This is a lazy operation the function reads the file header, but the actual image data is not read from the file until you try to process the data (call the load method to force loading). Opens and identifies the given image file.
0 Comments
Leave a Reply. |