MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __init__

Method __init__

tools/python-3.11.9-amd64/Lib/email/mime/image.py:16–43  ·  view source on GitHub ↗

Create an image/* type MIME document. _imagedata contains the bytes for the raw image data. If the data type can be detected (jpeg, png, gif, tiff, rgb, pbm, pgm, ppm, rast, xbm, bmp, webp, and exr attempted), then the subtype will be automatically included in

(self, _imagedata, _subtype=None,
                 _encoder=encoders.encode_base64, *, policy=None, **_params)

Source from the content-addressed store, hash-verified

14 """Class for generating image/* type MIME documents."""
15
16 def __init__(self, _imagedata, _subtype=None,
17 _encoder=encoders.encode_base64, *, policy=None, **_params):
18 """Create an image/* type MIME document.
19
20 _imagedata contains the bytes for the raw image data. If the data
21 type can be detected (jpeg, png, gif, tiff, rgb, pbm, pgm, ppm,
22 rast, xbm, bmp, webp, and exr attempted), then the subtype will be
23 automatically included in the Content-Type header. Otherwise, you can
24 specify the specific image subtype via the _subtype parameter.
25
26 _encoder is a function which will perform the actual encoding for
27 transport of the image data. It takes one argument, which is this
28 Image instance. It should use get_payload() and set_payload() to
29 change the payload to the encoded form. It should also add any
30 Content-Transfer-Encoding or other headers to the message as
31 necessary. The default encoding is Base64.
32
33 Any additional keyword arguments are passed to the base class
34 constructor, which turns them into parameters on the Content-Type
35 header.
36 """
37 _subtype = _what(_imagedata) if _subtype is None else _subtype
38 if _subtype is None:
39 raise TypeError('Could not guess image MIME subtype')
40 MIMENonMultipart.__init__(self, 'image', _subtype, policy=policy,
41 **_params)
42 self.set_payload(_imagedata)
43 _encoder(self)
44
45
46_rules = []

Callers

nothing calls this directly

Calls 2

set_payloadMethod · 0.80
_whatFunction · 0.70

Tested by

no test coverage detected