id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
174,033 | from struct import pack, unpack_from
def unpack_from(__format: _FmtType, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ...
The provided code snippet includes necessary dependencies for implementing the `si16be` function. Write a Python function `def si16be(c, o=0)` to solve the following problem:
Conver... | Converts a 2-bytes (16 bits) string to a signed integer, big endian. :param c: string containing bytes to convert :param o: offset of bytes to convert in string |
174,034 | from struct import pack, unpack_from
def unpack_from(__format: _FmtType, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ...
The provided code snippet includes necessary dependencies for implementing the `i32le` function. Write a Python function `def i32le(c, o=0)` to solve the following problem:
Converts... | Converts a 4-bytes (32 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string |
174,035 | from struct import pack, unpack_from
def unpack_from(__format: _FmtType, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ...
The provided code snippet includes necessary dependencies for implementing the `si32le` function. Write a Python function `def si32le(c, o=0)` to solve the following problem:
Conver... | Converts a 4-bytes (32 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string |
174,036 | from struct import pack, unpack_from
def unpack_from(__format: _FmtType, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ...
def i32be(c, o=0):
return unpack_from(">I", c, o)[0] | null |
174,037 | from struct import pack, unpack_from
def pack(fmt: _FmtType, *v: Any) -> bytes: ...
def o16le(i):
return pack("<H", i) | null |
174,038 | from struct import pack, unpack_from
def pack(fmt: _FmtType, *v: Any) -> bytes: ...
def o32be(i):
return pack(">I", i) | null |
174,041 | from . import Image, ImageFile
from ._binary import i32le as i32
class WalImageFile(ImageFile.ImageFile):
format = "WAL"
format_description = "Quake2 Texture"
def _open(self):
self.mode = "P"
# read header fields
header = self.fp.read(32 + 24 + 32 + 12)
self._size = i32(heade... | Load texture from a Quake2 WAL texture file. By default, a Quake2 standard palette is attached to the texture. To override the palette, use the :py:func:`PIL.Image.Image.putpalette()` method. :param filename: WAL file name, or an opened file handle. :returns: An image instance. |
174,042 | import itertools
import math
import os
import subprocess
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16le as i16
from ._binary import o8
from ._binary import o16le as o16
def _accept(prefix):
return prefix[:6] in [b"GIF87a", b"GIF89a"] | null |
174,043 | import itertools
import math
import os
import subprocess
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16le as i16
from ._binary import o8
from ._binary import o16le as o16
def _save(im, fp, filename, save_all=False):
# header
if "palette"... | null |
174,044 | import itertools
import math
import os
import subprocess
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16le as i16
from ._binary import o8
from ._binary import o16le as o16
def _save_netpbm(im, fp, filename):
# Unused by default.
# To use... | null |
174,045 | import itertools
import math
import os
import subprocess
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16le as i16
from ._binary import o8
from ._binary import o16le as o16
def _normalize_palette(im, palette, info):
"""
Normalizes the pale... | Legacy Method to get Gif data from image. Warning:: May modify image data. :param im: Image object :param palette: bytes object containing the source palette, or .... :param info: encoderinfo :returns: tuple of(list of header items, optimized palette) |
174,046 | import itertools
import math
import os
import subprocess
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16le as i16
from ._binary import o8
from ._binary import o16le as o16
def _write_frame_data(fp, im_frame, offset, params):
try:
im_f... | Legacy Method Return a list of strings representing this image. The first string is a local image header, the rest contains encoded image data. To specify duration, add the time in milliseconds, e.g. ``getdata(im_frame, duration=1000)`` :param im: Image object :param offset: Tuple of (x, y) pixels. Defaults to (0, 0) :... |
174,047 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class Intent(IntEnum):
PERCEPTUAL = 0
RELATIVE_COLORIMETRIC = 1
SATURATION = 2
ABSOLUTE_COLORIMETRIC = 3
class Direction(IntEnum):
INPUT = 0
OUTPUT = 1
PROOF = 2
def deprecate(
deprecated: str,
... | null |
174,048 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
try:
from PIL import _imagingcms
except ImportError as ex:
# Allow error import for doc purposes, but error out when accessing
# anything in core.
from ._util import DeferredError
_imagingcms = DeferredError(... | (experimental) Fetches the profile for the current display device. :returns: ``None`` if the profile is not known. |
174,049 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class Intent(IntEnum):
PERCEPTUAL = 0
RELATIVE_COLORIMETRIC = 1
SATURATION = 2
ABSOLUTE_COLORIMETRIC = 3
_MAX_FLAG = 0
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: E... | (pyCMS) Applies an ICC transformation to a given image, mapping from ``inputProfile`` to ``outputProfile``. If the input or output profiles specified are not valid filenames, a :exc:`PyCMSError` will be raised. If ``inPlace`` is ``True`` and ``outputMode != im.mode``, a :exc:`PyCMSError` will be raised. If an error occ... |
174,050 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Opens an ICC profile file. The PyCMSProfile object can be passed back into pyCMS for use in creating transforms and such (as in ImageCms.buildTransformFromOpenProfiles()). If ``profileFilename`` is not a valid filename for an ICC profile, a :exc:`PyCMSError` will be raised. :param profileFilename: String, as a ... |
174,051 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class Intent(IntEnum):
PERCEPTUAL = 0
RELATIVE_COLORIMETRIC = 1
SATURATION = 2
ABSOLUTE_COLORIMETRIC = 3
_MAX_FLAG = 0
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: E... | (pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the ``outputProfile``. Use applyTransform to apply the transform to a given image. If the input or output profiles specified are not valid filenames, a :exc:`PyCMSError` will be raised. If an error occurs during creation of the transform, a :exc:`PyCM... |
174,052 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class Intent(IntEnum):
PERCEPTUAL = 0
RELATIVE_COLORIMETRIC = 1
SATURATION = 2
ABSOLUTE_COLORIMETRIC = 3
FLAGS = {
"MATRIXINPUT": 1,
"MATRIXOUTPUT": 2,
"MATRIXONLY": (1 | 2),
"NOWHITEONWHITEFIXUP"... | (pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the ``outputProfile``, but tries to simulate the result that would be obtained on the ``proofProfile`` device. If the input, output, or proof profiles specified are not valid filenames, a :exc:`PyCMSError` will be raised. If an error occurs during cre... |
174,053 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class PyCMSError(Exception):
"""(pyCMS) Exception class.
This is used for all errors in the pyCMS API."""
pass
The provided code snippet includes necessary dependencies for implementing the `applyTransform` function... | (pyCMS) Applies a transform to a given image. If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised. If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a :exc:`PyCMSError` is raised. If ``im.mode``, ``transform.inMode`` or ``transform.outMode`` is not supported by pyCMSdll or the prof... |
174,054 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
core = _imagingcms
class PyCMSError(Exception):
"""(pyCMS) Exception class.
This is used for all errors in the pyCMS API."""
pass
The provided code snippet includes necessary dependencies for implementing the `creat... | (pyCMS) Creates a profile. If colorSpace not in ``["LAB", "XYZ", "sRGB"]``, a :exc:`PyCMSError` is raised. If using LAB and ``colorTemp`` is not a positive integer, a :exc:`PyCMSError` is raised. If an error occurs while creating the profile, a :exc:`PyCMSError` is raised. Use this function to create common profiles on... |
174,055 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the internal product name for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised If an error occurs while trying to obtain the name tag, a :exc:`PyCMSError` is raised. Use this function to obtain the INTERNAL name of the profile (stored... |
174,056 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the internal product information for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised. If an error occurs while trying to obtain the info tag, a :exc:`PyCMSError` is raised. Use this function to obtain the information stored in the pr... |
174,057 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the copyright for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised. If an error occurs while trying to obtain the copyright tag, a :exc:`PyCMSError` is raised. Use this function to obtain the information stored in the profile's copyri... |
174,058 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the manufacturer for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised. If an error occurs while trying to obtain the manufacturer tag, a :exc:`PyCMSError` is raised. Use this function to obtain the information stored in the profile's ... |
174,059 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the model for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised. If an error occurs while trying to obtain the model tag, a :exc:`PyCMSError` is raised. Use this function to obtain the information stored in the profile's model tag. :pa... |
174,060 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the description for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised. If an error occurs while trying to obtain the description tag, a :exc:`PyCMSError` is raised. Use this function to obtain the information stored in the profile's de... |
174,061 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Gets the default intent name for the given profile. If ``profile`` isn't a valid CmsProfile object or filename to a profile, a :exc:`PyCMSError` is raised. If an error occurs while trying to obtain the default intent, a :exc:`PyCMSError` is raised. Use this function to determine the default (and usually best op... |
174,062 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
class ImageCmsProfile:
def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
... | (pyCMS) Checks if a given intent is supported. Use this function to verify that you can use your desired ``intent`` with ``profile``, and that ``profile`` can be used for the input/output/proof profile as you desire. Some profiles are created specifically for one "direction", can cannot be used for others. Some profile... |
174,063 | import sys
from enum import IntEnum
from PIL import Image
from ._deprecate import deprecate
VERSION = "1.0.0 pil"
core = _imagingcms
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 r... | (pyCMS) Fetches versions. |
174,064 | import functools
import operator
import re
from . import Image, ImagePalette
def _lut(image, lut):
if image.mode == "P":
# FIXME: apply to lookup table, not image data
msg = "mode P support coming soon"
raise NotImplementedError(msg)
elif image.mode in ("L", "RGB"):
if image.mode... | Maximize (normalize) image contrast. This function calculates a histogram of the input image (or mask region), removes ``cutoff`` percent of the lightest and darkest pixels from the histogram, and remaps the image so that the darkest pixel becomes black (0), and the lightest becomes white (255). :param image: The image... |
174,065 | import functools
import operator
import re
from . import Image, ImagePalette
def _color(color, mode):
if isinstance(color, str):
from . import ImageColor
color = ImageColor.getcolor(color, mode)
return color
def _lut(image, lut):
if image.mode == "P":
# FIXME: apply to lookup table, ... | Colorize grayscale image. This function calculates a color wedge which maps all black pixels in the source image to the first color and all white pixels to the second color. If ``mid`` is specified, it uses three-color mapping. The ``black`` and ``white`` arguments should be RGB tuples or color names; optionally you ca... |
174,066 | import functools
import operator
import re
from . import Image, ImagePalette
def contain(image, size, method=Image.Resampling.BICUBIC):
"""
Returns a resized version of the image, set to the maximum width and height
within the requested size, while maintaining the original aspect ratio.
:param image: Th... | Returns a resized and padded version of the image, expanded to fill the requested aspect ratio and size. :param image: The image to resize and crop. :param size: The requested output size in pixels, given as a (width, height) tuple. :param method: Resampling method to use. Default is :py:attr:`~PIL.Image.Resampling.BIC... |
174,067 | import functools
import operator
import re
from . import Image, ImagePalette
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.
*... | Deform the image. :param image: The image to deform. :param deformer: A deformer object. Any object that implements a ``getmesh`` method can be used. :param resample: An optional resampling filter. Same values possible as in the PIL.Image.transform function. :return: An image. |
174,068 | import functools
import operator
import re
from . import Image, ImagePalette
def _lut(image, lut):
if image.mode == "P":
# FIXME: apply to lookup table, not image data
msg = "mode P support coming soon"
raise NotImplementedError(msg)
elif image.mode in ("L", "RGB"):
if image.mode... | Equalize the image histogram. This function applies a non-linear mapping to the input image, in order to create a uniform distribution of grayscale values in the output image. :param image: The image to equalize. :param mask: An optional mask. If given, only the pixels selected by the mask are included in the analysis.... |
174,069 | import functools
import operator
import re
from . import Image, ImagePalette
def _border(border):
if isinstance(border, tuple):
if len(border) == 2:
left, top = right, bottom = border
elif len(border) == 4:
left, top, right, bottom = border
else:
left = top = righ... | Add border to the image :param image: The image to expand. :param border: Border width, in pixels. :param fill: Pixel fill value (a color value). Default is 0 (black). :return: An image. |
174,070 | import functools
import operator
import re
from . import Image, ImagePalette
def crop(image, border=0):
"""
Remove border from image. The same amount of pixels are removed
from all four sides. This function works on all image modes.
.. seealso:: :py:meth:`~PIL.Image.Image.crop`
:param image: The i... | Returns a resized and cropped version of the image, cropped to the requested aspect ratio and size. This function was contributed by Kevin Cazabon. :param image: The image to resize and crop. :param size: The requested output size in pixels, given as a (width, height) tuple. :param method: Resampling method to use. Def... |
174,071 | import functools
import operator
import re
from . import Image, ImagePalette
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.
*... | Flip the image vertically (top to bottom). :param image: The image to flip. :return: An image. |
174,072 | import functools
import operator
import re
from . import Image, ImagePalette
The provided code snippet includes necessary dependencies for implementing the `grayscale` function. Write a Python function `def grayscale(image)` to solve the following problem:
Convert the image to grayscale. :param image: The image to con... | Convert the image to grayscale. :param image: The image to convert. :return: An image. |
174,073 | import functools
import operator
import re
from . import Image, ImagePalette
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.
*... | Flip image horizontally (left to right). :param image: The image to mirror. :return: An image. |
174,074 | import functools
import operator
import re
from . import Image, ImagePalette
def _lut(image, lut):
if image.mode == "P":
# FIXME: apply to lookup table, not image data
msg = "mode P support coming soon"
raise NotImplementedError(msg)
elif image.mode in ("L", "RGB"):
if image.mode... | Reduce the number of bits for each color channel. :param image: The image to posterize. :param bits: The number of bits to keep for each channel (1-8). :return: An image. |
174,075 | import functools
import operator
import re
from . import Image, ImagePalette
def _lut(image, lut):
if image.mode == "P":
# FIXME: apply to lookup table, not image data
msg = "mode P support coming soon"
raise NotImplementedError(msg)
elif image.mode in ("L", "RGB"):
if image.mode... | Invert all pixel values above a threshold. :param image: The image to solarize. :param threshold: All pixels above this greyscale level are inverted. :return: An image. |
174,076 | import functools
import operator
import re
from . import Image, ImagePalette
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.
*... | If an image has an EXIF Orientation tag, other than 1, return a new image that is transposed accordingly. The new image will have the orientation data removed. Otherwise, return a copy of the image. :param image: The image to transpose. :return: An image. |
174,079 | import io
import os
import re
import subprocess
import sys
import tempfile
from . import Image, ImageFile
from ._binary import i32le as i32
from ._deprecate import deprecate
gs_windows_binary = None
if sys.platform.startswith("win"):
import shutil
for binary in ("gswin32c", "gswin64c", "gs"):
if shutil.... | null |
174,080 | import io
import os
import re
import subprocess
import sys
import tempfile
from . import Image, ImageFile
from ._binary import i32le as i32
from ._deprecate import deprecate
gs_windows_binary = None
if sys.platform.startswith("win"):
import shutil
for binary in ("gswin32c", "gswin64c", "gs"):
if shutil.... | Render an image using Ghostscript |
174,081 | import io
import os
import re
import subprocess
import sys
import tempfile
from . import Image, ImageFile
from ._binary import i32le as i32
from ._deprecate import deprecate
def _accept(prefix):
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5) | null |
174,082 | import io
import os
import re
import subprocess
import sys
import tempfile
from . import Image, ImageFile
from ._binary import i32le as i32
from ._deprecate import deprecate
class ImageFile(Image.Image):
"""Base class for image file format handlers."""
def __init__(self, fp=None, filename=None):
super... | EPS Writer for the Python Imaging Library. |
174,083 | from . import FontFile, Image
class Image:
def __init__(self):
def __getattr__(self, name):
def width(self):
def height(self):
def size(self):
def _new(self, im):
def __enter__(self):
def __exit__(self, *args):
def close(self):
def _copy(self):
def _ensure_mutable... | null |
174,084 | import warnings
from . import Image, ImageFile, ImagePalette
from ._binary import i16le as i16
from ._binary import o8
from ._binary import o16le as o16
SAVE = {
"1": ("1", 1, 0, 3),
"L": ("L", 8, 0, 3),
"LA": ("LA", 16, 0, 3),
"P": ("P", 8, 1, 1),
"RGB": ("BGR", 24, 0, 2),
"RGBA": ("BGRA", 32, ... | null |
174,086 | from . import Image, ImageFile
def _accept(prefix):
return prefix[:4] == b"GRIB" and prefix[7] == 1 | null |
174,087 | from . import Image, ImageFile
_handler = None
def _save(im, fp, filename):
if _handler is None or not hasattr(_handler, "save"):
msg = "GRIB save handler not installed"
raise OSError(msg)
_handler.save(im, fp, filename) | null |
174,089 | import builtins
from . import Image, _imagingmath
class _Operand:
"""Wraps an image operand, providing standard operators"""
def __init__(self, im):
self.im = im
def __fixup(self, im1):
# convert image to suitable mode
if isinstance(im1, _Operand):
# argument was an image... | null |
174,090 | import builtins
from . import Image, _imagingmath
class _Operand:
"""Wraps an image operand, providing standard operators"""
def __init__(self, im):
self.im = im
def __fixup(self, im1):
# convert image to suitable mode
if isinstance(im1, _Operand):
# argument was an image... | null |
174,095 | import builtins
from . import Image, _imagingmath
class _Operand:
def __init__(self, im):
def __fixup(self, im1):
def apply(self, op, im1, im2=None, mode=None):
def __bool__(self):
def __abs__(self):
def __pos__(self):
def __neg__(self):
def __add__(self, other):
def __radd_... | null |
174,096 | import builtins
from . import Image, _imagingmath
class _Operand:
"""Wraps an image operand, providing standard operators"""
def __init__(self, im):
self.im = im
def __fixup(self, im1):
# convert image to suitable mode
if isinstance(im1, _Operand):
# argument was an image... | Evaluates an image expression. :param expression: A string containing a Python-style expression. :param options: Values to add to the evaluation context. You can either use a dictionary, or one or more keyword arguments. :return: The evaluated expression. This is usually an image object, but can also be an integer, a f... |
174,097 | import sys
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_path
def fromqimage(im):
"""
:param im: QImage or PIL ImageQt object
"""
buffer = QBuffer()
if qt_version == "6":
try:
qt_openmode = QIODevice.OpenModeFlag
except... | null |
174,098 | import sys
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_path
for qt_version, qt_module in qt_versions:
try:
if qt_module == "PyQt6":
from PyQt6.QtCore import QBuffer, QIODevice
from PyQt6.QtGui import QImage, QPixmap, qRgba
... | null |
174,099 | import sys
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_path
def toqimage(im):
return ImageQt(im)
def toqpixmap(im):
# # This doesn't work. For now using a dumb approach.
# im_data = _toqclass_helper(im)
# result = QPixmap(im_data["size"][0], im_dat... | null |
174,100 | from collections import namedtuple
class TagInfo(namedtuple("_TagInfo", "value name type length enum")):
__slots__ = []
def __new__(cls, value=None, name="unknown", type=None, length=None, enum=None):
return super().__new__(cls, value, name, type, length, enum or {})
def cvt_enum(self, value):
... | null |
174,102 | import re
from . import Image, ImageFile
class ImageFile(Image.Image):
def __init__(self, fp=None, filename=None):
def get_format_mimetype(self):
def __setstate__(self, state):
def verify(self):
def load(self):
def load_prepare(self):
def load_end(self):
def _seek_check(self, fr... | null |
174,103 | import io
import itertools
import logging
import math
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 i16be as i16
from ._binary im... | null |
174,104 | import io
import itertools
import logging
import math
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 i16be as i16
from ._binary im... | null |
174,105 | import io
import itertools
import logging
import math
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 i16be as i16
from ._binary im... | null |
174,106 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,107 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,108 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,109 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,110 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,111 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,112 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,113 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,114 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,115 | import array
import io
import math
import os
import struct
import subprocess
import sys
import tempfile
import warnings
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._deprecate import deprecate
from .Jpe... | null |
174,116 | import os
import shutil
import subprocess
import sys
import tempfile
from . import Image
class Image:
def __init__(self):
def __getattr__(self, name):
def width(self):
def height(self):
def size(self):
def _new(self, im):
def __enter__(self):
def __exit__(self, *args):
def ... | null |
174,117 | import os
import shutil
import subprocess
import sys
import tempfile
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
dire... | null |
174,120 | import os
import re
from . import Image, ImageFile, ImagePalette
for i in ["8", "8S", "16", "16S", "32", "32F"]:
OPEN[f"L {i} image"] = ("F", f"F;{i}")
OPEN[f"L*{i} image"] = ("F", f"F;{i}")
for i in ["16", "16L", "16B"]:
OPEN[f"L {i} image"] = (f"I;{i}", f"I;{i}")
OPEN[f"L*{i} image"] = (f"I;{i}", f"I;... | null |
174,122 | import os
from . import Image, ImageFile
from ._binary import i32be as i32
from ._binary import o8
def _accept(prefix):
return prefix[:4] == b"qoif" | null |
174,123 | from math import log, pi, sin, sqrt
from ._binary import o8
EPSILON = 1e-10
def log(x: SupportsFloat, base: SupportsFloat = ...) -> float: ...
def curved(middle, pos):
return pos ** (log(0.5) / log(max(middle, EPSILON))) | null |
174,124 | from math import log, pi, sin, sqrt
from ._binary import o8
def linear(middle, pos):
pi: float
def sin(__x: SupportsFloat) -> float:
def sine(middle, pos):
return (sin((-pi / 2.0) + pi * linear(middle, pos)) + 1.0) / 2.0 | null |
174,125 | 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 |
174,126 | from math import log, pi, sin, sqrt
from ._binary import o8
def linear(middle, pos):
def sqrt(__x: SupportsFloat) -> float:
def sphere_decreasing(middle, pos):
return 1.0 - sqrt(1.0 - linear(middle, pos) ** 2) | null |
174,127 | import os
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 |
174,128 | import os
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 |
174,129 | import os
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]
... | null |
174,130 | import os
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]
and i16(prefix, 14) in [0, 3] # flags
) | null |
174,131 | 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 o8
from ._binary import o16le as o16
from ._binary import o32le as o32
_MAGIC = b"\0\0\1\0"
Image.regi... | null |
174,132 | 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 o8
from ._binary import o16le as o16
from ._binary import o32le as o32
_MAGIC = b"\0\0\1\0"
def _acce... | null |
174,133 | import array
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
from ._deprecate import deprecate
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 op... | null |
174,134 | import array
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
from ._deprecate import deprecate
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 |
174,135 | import array
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
from ._deprecate import deprecate
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 op... | null |
174,136 | import array
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
from ._deprecate import deprecate
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 op... | null |
174,137 | import array
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
from ._deprecate import deprecate
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 op... | null |
174,138 | from . import FitsImagePlugin, Image, ImageFile
from ._deprecate import deprecate
_handler = None
class FITSStubImageFile(ImageFile.StubImageFile):
format = FitsImagePlugin.FitsImageFile.format
format_description = FitsImagePlugin.FitsImageFile.format_description
def _open(self):
offset = self.fp.te... | Install application-specific FITS image handler. :param handler: Handler object. |
174,139 | from . import FitsImagePlugin, Image, ImageFile
from ._deprecate import deprecate
def _save(im, fp, filename):
msg = "FITS save handler not installed"
raise OSError(msg) | null |
174,141 | 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_ALPHAPIXELS = 0x1
DDPF_RGB = 0x40
DDPF_LUMINANCE = 0x20000
Image.regist... | null |
174,143 | import os
import shutil
import subprocess
import sys
from shlex import quote
from PIL import Image
from ._deprecate import deprecate
_viewers = []
class Viewer:
"""Base class for viewers."""
# main api
def show(self, image, **options):
"""
The main function for displaying an image.
C... | The :py:func:`register` function is used to register additional viewers:: from PIL import ImageShow ImageShow.register(MyViewer()) # MyViewer will be used as a last resort ImageShow.register(MySecondViewer(), 0) # MySecondViewer will be prioritised ImageShow.register(ImageShow.XVViewer(), 0) # XVViewer will be prioriti... |
174,144 | import itertools
import os
import struct
from . import (
ExifTags,
Image,
ImageFile,
ImageSequence,
JpegImagePlugin,
TiffImagePlugin,
)
from ._binary import i16be as i16
from ._binary import o32le
def _save(im, fp, filename):
Image.register_save(MpoImageFile.format, _save)
Image.register_save_al... | null |
174,145 | import io
import os
import struct
from . import Image, ImageFile, _binary
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 a... | Parse the JPEG 2000 codestream to extract the size and component count from the SIZ marker segment, returning a PIL (size, mode) tuple. |
174,146 | import io
import os
import struct
from . import Image, ImageFile, _binary
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 ... | Parse the JP2 header box to extract size, component count, color space information, and optionally DPI information, returning a (size, mode, mimetype, dpi) tuple. |
174,147 | import io
import os
import struct
from . import Image, ImageFile, _binary
def _accept(prefix):
return (
prefix[:4] == b"\xff\x4f\xff\x51"
or prefix[:12] == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a"
) | null |
174,148 | import io
import os
import struct
from . import Image, ImageFile, _binary
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 =... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.