id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
167,665
import re from . import Image, ImageFile class ImageFile(Image.Image): """Base class for image file format handlers.""" def __init__(self, fp=None, filename=None): super().__init__() self._min_frame = 0 self.custom_mimetype = None self.tile = None """ A list of tile ...
null
167,666
import io import itertools import logging import os import struct import warnings from collections.abc import MutableMapping from fractions import Fraction from numbers import Number, Rational from . import Image, ImageFile, ImageOps, ImagePalette, TiffTags from ._binary import o8 from .TiffTags import TYPES PREFIXES =...
null
167,667
import io import itertools import logging import os import struct import warnings from collections.abc import MutableMapping from fractions import Fraction from numbers import Number, Rational from . import Image, ImageFile, ImageOps, ImagePalette, TiffTags from ._binary import o8 from .TiffTags import TYPES def _limit...
null
167,668
import io import itertools import logging import os import struct import warnings from collections.abc import MutableMapping from fractions import Fraction from numbers import Number, Rational from . import Image, ImageFile, ImageOps, ImagePalette, TiffTags from ._binary import o8 from .TiffTags import TYPES for idx, n...
null
167,669
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets class ImageFile(Image.Imag...
null
167,670
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets class ImageFile(Image.Imag...
null
167,671
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets class ImageFile(Image.Imag...
null
167,672
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets class ImageFile(Image.Imag...
null
167,673
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets zigzag_index = ( 0, 1,...
null
167,674
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets def _accept(prefix): #...
null
167,675
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets def _getexif(self): if...
null
167,676
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets def convert_dict_qtables(q...
null
167,677
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets RAWMODE = { "1": "L", ...
null
167,678
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets def _save_cjpeg(im, fp, fi...
null
167,679
import array import io import math import os import struct import subprocess import sys import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from .JpegPresets import presets class JpegImageFile(ImageFi...
null
167,680
import sys from . import Image if sys.platform == "darwin": import os import subprocess import tempfile class Image: """ This class represents an image object. To create :py:class:`~PIL.Image.Image` objects, use the appropriate factory functions. There's hardly ever any reason to call the...
null
167,681
import sys from . import Image if sys.platform == "darwin": import os import subprocess import tempfile class Image: """ This class represents an image object. To create :py:class:`~PIL.Image.Image` objects, use the appropriate factory functions. There's hardly ever any reason to call the...
null
167,682
import io from . import FontFile, Image from ._binary import i8 from ._binary import i16be as b16 from ._binary import i16le as l16 from ._binary import i32be as b32 from ._binary import i32le as l32 def sz(s, o): return s[o : s.index(b"\0", o)]
null
167,683
import os import re from . import Image, ImageFile, ImagePalette def number(s): try: return int(s) except ValueError: return float(s)
null
167,684
import os import re from . import Image, ImageFile, ImagePalette SAVE = { # mode: (im type, raw mode) "1": ("0 1", "1"), "L": ("Greyscale", "L"), "LA": ("LA", "LA;L"), "P": ("Greyscale", "P"), "PA": ("LA", "PA;L"), "I": ("L 32S", "I;32S"), "I;16": ("L 16", "I;16"), "I;16L": ("L 16L",...
null
167,685
import os from . import Image, _binary The provided code snippet includes necessary dependencies for implementing the `puti16` function. Write a Python function `def puti16(fp, values)` to solve the following problem: Write network order (big-endian) 16-bit sequence Here is the function: def puti16(fp, values): ...
Write network order (big-endian) 16-bit sequence
167,686
from math import log, pi, sin, sqrt from ._binary import o8 EPSILON = 1e-10 def curved(middle, pos): return pos ** (log(0.5) / log(max(middle, EPSILON)))
null
167,687
from math import log, pi, sin, sqrt from ._binary import o8 def linear(middle, pos): if pos <= middle: if middle < EPSILON: return 0.0 else: return 0.5 * pos / middle else: pos = pos - middle middle = 1.0 - middle if middle < EPSILON: r...
null
167,688
from math import log, pi, sin, sqrt from ._binary import o8 def linear(middle, pos): if pos <= middle: if middle < EPSILON: return 0.0 else: return 0.5 * pos / middle else: pos = pos - middle middle = 1.0 - middle if middle < EPSILON: r...
null
167,689
from math import log, pi, sin, sqrt from ._binary import o8 def linear(middle, pos): def sphere_decreasing(middle, pos): return 1.0 - sqrt(1.0 - linear(middle, pos) ** 2)
null
167,690
from . import Image, ImageFile, ImagePalette from ._binary import i16le as i16 from ._binary import i32le as i32 from ._binary import o8 from ._binary import o16le as o16 from ._binary import o32le as o32 def _accept(prefix): return prefix[:2] == b"BM"
null
167,691
from . import Image, ImageFile, ImagePalette from ._binary import i16le as i16 from ._binary import i32le as i32 from ._binary import o8 from ._binary import o16le as o16 from ._binary import o32le as o32 def _dib_accept(prefix): return i32(prefix) in [12, 40, 64, 108, 124]
null
167,692
from . import Image, ImageFile, ImagePalette from ._binary import i16le as i16 from ._binary import i32le as i32 from ._binary import o8 from ._binary import o16le as o16 from ._binary import o32le as o32 def _save(im, fp, filename, bitmap_header=True): try: rawmode, bits, colors = SAVE[im.mode] except ...
null
167,693
from . import Image, ImageFile, ImagePalette from ._binary import i16le as i16 from ._binary import i32le as i32 from ._binary import o8 def _accept(prefix): return len(prefix) >= 6 and i16(prefix, 4) in [0xAF11, 0xAF12]
null
167,694
import struct import warnings from io import BytesIO from math import ceil, log from . import BmpImagePlugin, Image, ImageFile, PngImagePlugin from ._binary import i16le as i16 from ._binary import i32le as i32 from ._binary import o32le as o32 _MAGIC = b"\0\0\1\0" Image.register_open(IcoImageFile.format, IcoImageFile,...
null
167,695
import struct import warnings from io import BytesIO from math import ceil, log from . import BmpImagePlugin, Image, ImageFile, PngImagePlugin from ._binary import i16le as i16 from ._binary import i32le as i32 from ._binary import o32le as o32 _MAGIC = b"\0\0\1\0" def _accept(prefix): return prefix[:4] == _MAGIC
null
167,696
import array import warnings from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile class ImagePalette: """ Color palette for palette mapped images :param mode: The mode to use for the palette. See: :ref:`concept-modes`. Defaults to "RGB" :param palette: An optional palette. If...
null
167,697
import array import warnings from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile def make_gamma_lut(exp): lut = [] for i in range(256): lut.append(int(((i / 255.0) ** exp) * 255.0 + 0.5)) return lut
null
167,698
import array import warnings from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile class ImagePalette: """ Color palette for palette mapped images :param mode: The mode to use for the palette. See: :ref:`concept-modes`. Defaults to "RGB" :param palette: An optional palette. If...
null
167,699
import array import warnings from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile class ImagePalette: """ Color palette for palette mapped images :param mode: The mode to use for the palette. See: :ref:`concept-modes`. Defaults to "RGB" :param palette: An optional palette. If...
null
167,700
import array import warnings from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile class ImagePalette: """ Color palette for palette mapped images :param mode: The mode to use for the palette. See: :ref:`concept-modes`. Defaults to "RGB" :param palette: An optional palette. If...
null
167,701
from . import Image, ImageFile _handler = None The provided code snippet includes necessary dependencies for implementing the `register_handler` function. Write a Python function `def register_handler(handler)` to solve the following problem: Install application-specific FITS image handler. :param handler: Handler obj...
Install application-specific FITS image handler. :param handler: Handler object.
167,702
from . import Image, ImageFile def _accept(prefix): return prefix[:6] == b"SIMPLE"
null
167,703
from . import Image, ImageFile _handler = None def _save(im, fp, filename): if _handler is None or not hasattr("_handler", "save"): raise OSError("FITS save handler not installed") _handler.save(im, fp, filename)
null
167,704
from . import BmpImagePlugin, Image from ._binary import i16le as i16 from ._binary import i32le as i32 def _accept(prefix): return prefix[:4] == b"\0\0\2\0"
null
167,705
import struct from io import BytesIO from . import Image, ImageFile from ._binary import o32le as o32 DDS_MAGIC = 0x20534444 DDSD_CAPS = 0x1 DDSD_HEIGHT = 0x2 DDSD_WIDTH = 0x4 DDSD_PITCH = 0x8 DDSD_PIXELFORMAT = 0x1000 DDSCAPS_TEXTURE = 0x1000 DDPF_RGB = 0x40 DDS_RGBA = DDPF_RGB | DDPF_ALPHAPIXELS Image.register_open(D...
null
167,706
import struct from io import BytesIO from . import Image, ImageFile from ._binary import o32le as o32 def _accept(prefix): return prefix[:4] == b"DDS "
null
167,707
import os import shutil import subprocess import sys from shlex import quote from PIL import Image _viewers = [] class Viewer: """Base class for viewers.""" # main api def show(self, image, **options): """ The main function for displaying an image. Converts the given image to the tar...
The :py:func:`register` function is used to register additional viewers. :param viewer: The viewer to be registered. :param order: Zero or a negative integer to prepend this viewer to the list, a positive integer to append it.
167,708
from . import Image, ImageFile, JpegImagePlugin from ._binary import i16be as i16 def _save(im, fp, filename): # Note that we can only save the current frame at present return JpegImagePlugin._save(im, fp, filename)
null
167,709
import io import os import struct from . import Image, ImageFile The provided code snippet includes necessary dependencies for implementing the `_parse_codestream` function. Write a Python function `def _parse_codestream(fp)` to solve the following problem: Parse the JPEG 2000 codestream to extract the size and compon...
Parse the JPEG 2000 codestream to extract the size and component count from the SIZ marker segment, returning a PIL (size, mode) tuple.
167,710
import io import os import struct from . import Image, ImageFile class BoxReader: """ A small helper class to read fields stored in JPEG2000 header boxes and to easily step into and read sub-boxes. """ def __init__(self, fp, length=-1): self.fp = fp self.has_length = length >= 0 ...
Parse the JP2 header box to extract size, component count, color space information, and optionally DPI information, returning a (size, mode, mimetype, dpi) tuple.
167,711
import io import os import struct from . import Image, ImageFile def _accept(prefix): return ( prefix[:4] == b"\xff\x4f\xff\x51" or prefix[:12] == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a" )
null
167,712
import io import os import struct from . import Image, ImageFile class ImageFile(Image.Image): def __init__(self, fp=None, filename=None): def get_format_mimetype(self): def verify(self): def load(self): def load_prepare(self): def load_end(self): def _seek_check(self, frame): def _...
null
167,713
import io from . import Image, ImageFile, ImagePalette from ._binary import i8 from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import si16be as si16 def _accept(prefix): return prefix[:4] == b"8BPS"
null
167,714
import io from . import Image, ImageFile, ImagePalette from ._binary import i8 from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import si16be as si16 def _maketile(file, mode, bbox, channels): class ImageFile(Image.Image): def __init__(self, fp=None, filename=None): def get_f...
null
167,715
import base64 import os import sys from io import BytesIO from . import Image from ._util import isDirectory, isPath class FreeTypeFont: "FreeType font wrapper (requires _imagingft service)" def __init__(self, font=None, size=10, index=0, encoding="", layout_engine=None): # FIXME: use service provider i...
Load a TrueType or OpenType font from a file or file-like object, and create a font object. This function loads a font object from the given file or file-like object, and creates a font object for a font of the given size. Pillow uses FreeType to open font files. If you are opening many fonts simultaneously on Windows,...
167,716
import base64 import os import sys from io import BytesIO from . import Image from ._util import isDirectory, isPath def load(filename): """ Load a font file. This function loads a font object from the given bitmap font file, and returns the corresponding font object. :param filename: Name of font file...
Load font file. Same as :py:func:`~PIL.ImageFont.load`, but searches for a bitmap font along the Python path. :param filename: Name of font file. :return: A font object. :exception OSError: If the file could not be read.
167,717
import base64 import os import sys from io import BytesIO from . import Image from ._util import isDirectory, isPath class ImageFont: "PIL font wrapper" def _load_pilfont(self, filename): with open(filename, "rb") as fp: image = None for ext in (".png", ".gif", ".pbm"): ...
Load a "better than nothing" default font. .. versionadded:: 1.1.4 :return: A font object.
167,718
from . import ImageFile, ImagePalette, UnidentifiedImageError from ._binary import i16be as i16 from ._binary import i32be as i32 class GdImageFile(ImageFile.ImageFile): """ Image plugin for the GD uncompressed format. Note that this format is not supported by the standard :py:func:`PIL.Image.open()` funct...
Load texture from a GD image file. :param filename: GD file name, or an opened file handle. :param mode: Optional mode. In this version, if the mode argument is given, it must be "r". :returns: An image instance. :raises OSError: If the image could not be read.
167,719
import itertools import logging import re import struct import warnings import zlib from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from ._binary import o16be as o16 from ._binary import o32be as o32 MAX_...
null
167,720
import itertools import logging import re import struct import warnings import zlib from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from ._binary import o16be as o16 from ._binary import o32be as o32 _MAG...
null
167,721
import itertools import logging import re import struct import warnings import zlib from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from ._binary import o16be as o16 from ._binary import o32be as o32 def ...
null
167,722
import itertools import logging import re import struct import warnings import zlib from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence from ._binary import i16be as i16 from ._binary import i32be as i32 from ._binary import o8 from ._binary import o16be as o16 from ._binary import o32be as o32 def ...
Return a list of PNG chunks representing this image.
167,723
import os import struct from . import Image, ImageFile from ._binary import i16be as i16 from ._binary import o8 def _accept(prefix): return len(prefix) >= 2 and i16(prefix) == 474
null
167,724
import os import struct from . import Image, ImageFile from ._binary import i16be as i16 from ._binary import o8 def o8(i): return bytes((i & 255,)) def _save(im, fp, filename): if im.mode != "RGB" and im.mode != "RGBA" and im.mode != "L": raise ValueError("Unsupported SGI image mode") # Get the ...
null
167,725
from . import Image, ImageFile _handler = None The provided code snippet includes necessary dependencies for implementing the `register_handler` function. Write a Python function `def register_handler(handler)` to solve the following problem: Install application-specific BUFR image handler. :param handler: Handler obj...
Install application-specific BUFR image handler. :param handler: Handler object.
167,726
from . import Image, ImageFile def _accept(prefix): return prefix[:4] == b"BUFR" or prefix[:4] == b"ZCZC"
null
167,727
from . import Image, ImageFile _handler = None def _save(im, fp, filename): if _handler is None or not hasattr("_handler", "save"): raise OSError("BUFR save handler not installed") _handler.save(im, fp, filename)
null
167,728
from . import Image, ImageFile, ImagePalette from ._binary import o8 _MAGIC = b"P7 332" def _accept(prefix): return prefix[:6] == _MAGIC
null
167,729
import struct from io import BytesIO from . import Image, ImageFile def unpack_565(i): return (((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3) The provided code snippet includes necessary dependencies for implementing the `decode_dxt1` function. Write a Python function `def decode_dxt1(data, alph...
input: one "row" of data (i.e. will produce 4*width pixels)
167,730
import struct from io import BytesIO from . import Image, ImageFile def unpack_565(i): return (((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3) The provided code snippet includes necessary dependencies for implementing the `decode_dxt3` function. Write a Python function `def decode_dxt3(data)` to ...
input: one "row" of data (i.e. will produce 4*width pixels)
167,731
import struct from io import BytesIO from . import Image, ImageFile def unpack_565(i): return (((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3) The provided code snippet includes necessary dependencies for implementing the `decode_dxt5` function. Write a Python function `def decode_dxt5(data)` to ...
input: one "row" of data (i.e. will produce 4 * width pixels)
167,732
import struct from io import BytesIO from . import Image, ImageFile def _accept(prefix): return prefix[:4] in (b"BLP1", b"BLP2")
null
167,733
from . import Image class Image: """ This class represents an image object. To create :py:class:`~PIL.Image.Image` objects, use the appropriate factory functions. There's hardly ever any reason to call the Image constructor directly. * :py:func:`~PIL.Image.open` * :py:func:`~PIL.Image.ne...
Fill a channel with a given grey level. :rtype: :py:class:`~PIL.Image.Image`
167,734
from . import Image The provided code snippet includes necessary dependencies for implementing the `duplicate` function. Write a Python function `def duplicate(image)` to solve the following problem: Copy a channel. Alias for :py:meth:`PIL.Image.Image.copy`. :rtype: :py:class:`~PIL.Image.Image` Here is the function: ...
Copy a channel. Alias for :py:meth:`PIL.Image.Image.copy`. :rtype: :py:class:`~PIL.Image.Image`
167,735
from . import Image The provided code snippet includes necessary dependencies for implementing the `invert` function. Write a Python function `def invert(image)` to solve the following problem: Invert an image (channel). .. code-block:: python out = MAX - image :rtype: :py:class:`~PIL.Image.Image` Here is the functio...
Invert an image (channel). .. code-block:: python out = MAX - image :rtype: :py:class:`~PIL.Image.Image`
167,736
from . import Image The provided code snippet includes necessary dependencies for implementing the `lighter` function. Write a Python function `def lighter(image1, image2)` to solve the following problem: Compares the two images, pixel by pixel, and returns a new image containing the lighter values. .. code-block:: py...
Compares the two images, pixel by pixel, and returns a new image containing the lighter values. .. code-block:: python out = max(image1, image2) :rtype: :py:class:`~PIL.Image.Image`
167,737
from . import Image The provided code snippet includes necessary dependencies for implementing the `darker` function. Write a Python function `def darker(image1, image2)` to solve the following problem: Compares the two images, pixel by pixel, and returns a new image containing the darker values. .. code-block:: pytho...
Compares the two images, pixel by pixel, and returns a new image containing the darker values. .. code-block:: python out = min(image1, image2) :rtype: :py:class:`~PIL.Image.Image`
167,738
from . import Image The provided code snippet includes necessary dependencies for implementing the `difference` function. Write a Python function `def difference(image1, image2)` to solve the following problem: Returns the absolute value of the pixel-by-pixel difference between the two images. .. code-block:: python o...
Returns the absolute value of the pixel-by-pixel difference between the two images. .. code-block:: python out = abs(image1 - image2) :rtype: :py:class:`~PIL.Image.Image`
167,739
from . import Image The provided code snippet includes necessary dependencies for implementing the `multiply` function. Write a Python function `def multiply(image1, image2)` to solve the following problem: Superimposes two images on top of each other. If you multiply an image with a solid black image, the result is b...
Superimposes two images on top of each other. If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected. .. code-block:: python out = image1 * image2 / MAX :rtype: :py:class:`~PIL.Image.Image`
167,740
from . import Image The provided code snippet includes necessary dependencies for implementing the `screen` function. Write a Python function `def screen(image1, image2)` to solve the following problem: Superimposes two inverted images on top of each other. .. code-block:: python out = MAX - ((MAX - image1) * (MAX - i...
Superimposes two inverted images on top of each other. .. code-block:: python out = MAX - ((MAX - image1) * (MAX - image2) / MAX) :rtype: :py:class:`~PIL.Image.Image`
167,741
from . import Image The provided code snippet includes necessary dependencies for implementing the `soft_light` function. Write a Python function `def soft_light(image1, image2)` to solve the following problem: Superimposes two images on top of each other using the Soft Light algorithm :rtype: :py:class:`~PIL.Image.Im...
Superimposes two images on top of each other using the Soft Light algorithm :rtype: :py:class:`~PIL.Image.Image`
167,742
from . import Image The provided code snippet includes necessary dependencies for implementing the `hard_light` function. Write a Python function `def hard_light(image1, image2)` to solve the following problem: Superimposes two images on top of each other using the Hard Light algorithm :rtype: :py:class:`~PIL.Image.Im...
Superimposes two images on top of each other using the Hard Light algorithm :rtype: :py:class:`~PIL.Image.Image`
167,743
from . import Image The provided code snippet includes necessary dependencies for implementing the `overlay` function. Write a Python function `def overlay(image1, image2)` to solve the following problem: Superimposes two images on top of each other using the Overlay algorithm :rtype: :py:class:`~PIL.Image.Image` Her...
Superimposes two images on top of each other using the Overlay algorithm :rtype: :py:class:`~PIL.Image.Image`
167,744
from . import Image The provided code snippet includes necessary dependencies for implementing the `add` function. Write a Python function `def add(image1, image2, scale=1.0, offset=0)` to solve the following problem: Adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1....
Adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. .. code-block:: python out = ((image1 + image2) / scale + offset) :rtype: :py:class:`~PIL.Image.Image`
167,745
from . import Image The provided code snippet includes necessary dependencies for implementing the `subtract` function. Write a Python function `def subtract(image1, image2, scale=1.0, offset=0)` to solve the following problem: Subtracts two images, dividing the result by scale and adding the offset. If omitted, scale...
Subtracts two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. .. code-block:: python out = ((image1 - image2) / scale + offset) :rtype: :py:class:`~PIL.Image.Image`
167,746
from . import Image The provided code snippet includes necessary dependencies for implementing the `add_modulo` function. Write a Python function `def add_modulo(image1, image2)` to solve the following problem: Add two images, without clipping the result. .. code-block:: python out = ((image1 + image2) % MAX) :rtype: ...
Add two images, without clipping the result. .. code-block:: python out = ((image1 + image2) % MAX) :rtype: :py:class:`~PIL.Image.Image`
167,747
from . import Image The provided code snippet includes necessary dependencies for implementing the `logical_and` function. Write a Python function `def logical_and(image1, image2)` to solve the following problem: Logical AND between two images. Both of the images must have mode "1". If you would like to perform a logi...
Logical AND between two images. Both of the images must have mode "1". If you would like to perform a logical AND on an image with a mode other than "1", try :py:meth:`~PIL.ImageChops.multiply` instead, using a black-and-white mask as the second image. .. code-block:: python out = ((image1 and image2) % MAX) :rtype: :p...
167,748
from . import Image The provided code snippet includes necessary dependencies for implementing the `logical_or` function. Write a Python function `def logical_or(image1, image2)` to solve the following problem: Logical OR between two images. Both of the images must have mode "1". .. code-block:: python out = ((image1 ...
Logical OR between two images. Both of the images must have mode "1". .. code-block:: python out = ((image1 or image2) % MAX) :rtype: :py:class:`~PIL.Image.Image`
167,749
from . import Image The provided code snippet includes necessary dependencies for implementing the `logical_xor` function. Write a Python function `def logical_xor(image1, image2)` to solve the following problem: Logical XOR between two images. Both of the images must have mode "1". .. code-block:: python out = ((bool...
Logical XOR between two images. Both of the images must have mode "1". .. code-block:: python out = ((bool(image1) != bool(image2)) % MAX) :rtype: :py:class:`~PIL.Image.Image`
167,750
from . import Image class Image: """ This class represents an image object. To create :py:class:`~PIL.Image.Image` objects, use the appropriate factory functions. There's hardly ever any reason to call the Image constructor directly. * :py:func:`~PIL.Image.open` * :py:func:`~PIL.Image.ne...
Create composite using transparency mask. Alias for :py:func:`PIL.Image.composite`. :rtype: :py:class:`~PIL.Image.Image`
167,751
from . import Image, ImageFile _handler = None The provided code snippet includes necessary dependencies for implementing the `register_handler` function. Write a Python function `def register_handler(handler)` to solve the following problem: Install application-specific HDF5 image handler. :param handler: Handler obj...
Install application-specific HDF5 image handler. :param handler: Handler object.
167,752
from . import Image, ImageFile def _accept(prefix): return prefix[:8] == b"\x89HDF\r\n\x1a\n"
null
167,753
from . import Image, ImageFile _handler = None def _save(im, fp, filename): if _handler is None or not hasattr("_handler", "save"): raise OSError("HDF5 save handler not installed") _handler.save(im, fp, filename)
null
167,754
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
null
167,755
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
Checks if an object is an image object. .. warning:: This function is for internal use only. :param t: object to check if it's an image :returns: True if the object is an image
167,756
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
null
167,757
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band. :param mode: Input mode. :returns: A tuple containing band names. The length of the tuple gives the numb...
167,758
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
null
167,759
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
null
167,760
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
null
167,761
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
Create greyscale wedge (for debugging only)
167,762
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
Creates an image memory from an object exporting the array interface (using the buffer protocol). If ``obj`` is not contiguous, then the ``tobytes`` method is called and :py:func:`~PIL.Image.frombuffer` is used. If you have an image in NumPy:: from PIL import Image import numpy as np im = Image.open("hopper.jpg") a = n...
167,763
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
Creates an image instance from a QPixmap image
167,764
import atexit import builtins import io import logging import math import numbers import os import re import struct import sys import tempfile import warnings from collections.abc import Callable, MutableMapping from pathlib import Path from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins fr...
Alpha composite im2 over im1. :param im1: The first image. Must have mode RGBA. :param im2: The second image. Must have mode RGBA, and the same size as the first image. :returns: An :py:class:`~PIL.Image.Image` object.