Create a PNG/JPEG/GIF image object given raw data. When this object is returned by an input cell or passed to the display function, it will result in the image being displayed in the frontend. Parameters ---------- data : unicode, str or bytes
(self, data=None, url=None, filename=None, format=None,
embed=None, width=None, height=None, retina=False,
unconfined=False, metadata=None)
| 1106 | } |
| 1107 | |
| 1108 | def __init__(self, data=None, url=None, filename=None, format=None, |
| 1109 | embed=None, width=None, height=None, retina=False, |
| 1110 | unconfined=False, metadata=None): |
| 1111 | """Create a PNG/JPEG/GIF image object given raw data. |
| 1112 | |
| 1113 | When this object is returned by an input cell or passed to the |
| 1114 | display function, it will result in the image being displayed |
| 1115 | in the frontend. |
| 1116 | |
| 1117 | Parameters |
| 1118 | ---------- |
| 1119 | data : unicode, str or bytes |
| 1120 | The raw image data or a URL or filename to load the data from. |
| 1121 | This always results in embedded image data. |
| 1122 | url : unicode |
| 1123 | A URL to download the data from. If you specify `url=`, |
| 1124 | the image data will not be embedded unless you also specify `embed=True`. |
| 1125 | filename : unicode |
| 1126 | Path to a local file to load the data from. |
| 1127 | Images from a file are always embedded. |
| 1128 | format : unicode |
| 1129 | The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given |
| 1130 | for format will be inferred from the filename extension. |
| 1131 | embed : bool |
| 1132 | Should the image data be embedded using a data URI (True) or be |
| 1133 | loaded using an <img> tag. Set this to True if you want the image |
| 1134 | to be viewable later with no internet connection in the notebook. |
| 1135 | |
| 1136 | Default is `True`, unless the keyword argument `url` is set, then |
| 1137 | default value is `False`. |
| 1138 | |
| 1139 | Note that QtConsole is not able to display images if `embed` is set to `False` |
| 1140 | width : int |
| 1141 | Width in pixels to which to constrain the image in html |
| 1142 | height : int |
| 1143 | Height in pixels to which to constrain the image in html |
| 1144 | retina : bool |
| 1145 | Automatically set the width and height to half of the measured |
| 1146 | width and height. |
| 1147 | This only works for embedded images because it reads the width/height |
| 1148 | from image data. |
| 1149 | For non-embedded images, you can just set the desired display width |
| 1150 | and height directly. |
| 1151 | unconfined: bool |
| 1152 | Set unconfined=True to disable max-width confinement of the image. |
| 1153 | metadata: dict |
| 1154 | Specify extra metadata to attach to the image. |
| 1155 | |
| 1156 | Examples |
| 1157 | -------- |
| 1158 | # embedded image data, works in qtconsole and notebook |
| 1159 | # when passed positionally, the first arg can be any of raw image data, |
| 1160 | # a URL, or a filename from which to load image data. |
| 1161 | # The result is always embedding image data for inline images. |
| 1162 | Image('http://www.google.fr/images/srpr/logo3w.png') |
| 1163 | Image('/path/to/image.jpg') |
| 1164 | Image(b'RAW_PNG_DATA...') |
| 1165 |
nothing calls this directly
no test coverage detected