MCPcopy Index your code
hub / github.com/plotly/plotly.py / Image

Class Image

_plotly_utils/png.py:1256–1300  ·  view source on GitHub ↗

A PNG image. You can create an :class:`Image` object from an array of pixels by calling :meth:`png.from_array`. It can be saved to disk with the :meth:`save` method.

Source from the content-addressed store, hash-verified

1254
1255
1256class Image:
1257 """A PNG image. You can create an :class:`Image` object from
1258 an array of pixels by calling :meth:`png.from_array`. It can be
1259 saved to disk with the :meth:`save` method.
1260 """
1261
1262 def __init__(self, rows, info):
1263 """
1264 .. note ::
1265
1266 The constructor is not public. Please do not call it.
1267 """
1268
1269 self.rows = rows
1270 self.info = info
1271
1272 def save(self, file):
1273 """Save the image to the named *file*.
1274
1275 See `.write()` if you already have an open file object.
1276
1277 In general, you can only call this method once;
1278 after it has been called the first time the PNG image is written,
1279 the source data will have been streamed, and
1280 cannot be streamed again.
1281 """
1282
1283 w = Writer(**self.info)
1284
1285 with open(file, "wb") as fd:
1286 w.write(fd, self.rows)
1287
1288 def write(self, file):
1289 """Write the image to the open file object.
1290
1291 See `.save()` if you have a filename.
1292
1293 In general, you can only call this method once;
1294 after it has been called the first time the PNG image is written,
1295 the source data will have been streamed, and
1296 cannot be streamed again.
1297 """
1298
1299 w = Writer(**self.info)
1300 w.write(file, self.rows)
1301
1302
1303class Reader:

Callers 1

from_arrayFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected