+++ /dev/null
-# Copyright (C) 2001-2006 Python Software Foundation\r
-# Author: Barry Warsaw\r
-# Contact: email-sig@python.org\r
-\r
-"""Class representing image/* type MIME documents."""\r
-\r
-__all__ = ['MIMEImage']\r
-\r
-import imghdr\r
-\r
-from email import encoders\r
-from email.mime.nonmultipart import MIMENonMultipart\r
-\r
-\r
-\f\r
-class MIMEImage(MIMENonMultipart):\r
- """Class for generating image/* type MIME documents."""\r
-\r
- def __init__(self, _imagedata, _subtype=None,\r
- _encoder=encoders.encode_base64, **_params):\r
- """Create an image/* type MIME document.\r
-\r
- _imagedata is a string containing the raw image data. If this data\r
- can be decoded by the standard Python `imghdr' module, then the\r
- subtype will be automatically included in the Content-Type header.\r
- Otherwise, you can specify the specific image subtype via the _subtype\r
- parameter.\r
-\r
- _encoder is a function which will perform the actual encoding for\r
- transport of the image data. It takes one argument, which is this\r
- Image instance. It should use get_payload() and set_payload() to\r
- change the payload to the encoded form. It should also add any\r
- Content-Transfer-Encoding or other headers to the message as\r
- necessary. The default encoding is Base64.\r
-\r
- Any additional keyword arguments are passed to the base class\r
- constructor, which turns them into parameters on the Content-Type\r
- header.\r
- """\r
- if _subtype is None:\r
- _subtype = imghdr.what(None, _imagedata)\r
- if _subtype is None:\r
- raise TypeError('Could not guess image MIME subtype')\r
- MIMENonMultipart.__init__(self, 'image', _subtype, **_params)\r
- self.set_payload(_imagedata)\r
- _encoder(self)\r