MCPcopy Index your code
hub / github.com/python/cpython / MIMEImage

Class MIMEImage

Lib/email/mime/image.py:13–43  ·  view source on GitHub ↗

Class for generating image/* type MIME documents.

Source from the content-addressed store, hash-verified

11
12
13class MIMEImage(MIMENonMultipart):
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 3

_make_imageMethod · 0.90
test_checkSetMinorMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 3

_make_imageMethod · 0.72
test_checkSetMinorMethod · 0.72
setUpMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…