This is a development version (9.14.0.dev) and may be unstable. Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.14.0.dev / IPython / core / display / Image / __init__

function

IPython.core.display:Image.__init__

source: /IPython/core/display.py :869

Signature

def   __init__ ( self data = None url = None filename = None format = None embed = None width = None height = None retina = False unconfined = False metadata = None alt = None )

Summary

Create a PNG/JPEG/GIF/WEBP image object given raw data.

Extended Summary

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

The raw image data or a URL or filename to load the data from. This always results in embedded image data.

url : unicode

A URL to download the data from. If you specify url=, the image data will not be embedded unless you also specify embed=True.

filename : unicode

Path to a local file to load the data from. Images from a file are always embedded.

format : unicode

The format of the image data (png/jpeg/jpg/gif/webp). If a filename or URL is given for format will be inferred from the filename extension.

embed : bool

Should the image data be embedded using a data URI (True) or be loaded using an <img> tag. Set this to True if you want the image to be viewable later with no internet connection in the notebook.

Default is True, unless the keyword argument url is set, then default value is False.

Note that QtConsole is not able to display images if embed is set to False

width : int

Width in pixels to which to constrain the image in html

height : int

Height in pixels to which to constrain the image in html

retina : bool

Automatically set the width and height to half of the measured width and height. This only works for embedded images because it reads the width/height from image data. For non-embedded images, you can just set the desired display width and height directly.

unconfined : bool

Set unconfined=True to disable max-width confinement of the image.

metadata : dict

Specify extra metadata to attach to the image.

alt : unicode

Alternative text for the image, for use by screen readers.

Examples

embedded image data, works in qtconsole and notebook when passed positionally, the first arg can be any of raw image data, a URL, or a filename from which to load image data. The result is always embedding image data for inline images.
Image('/path/to/image.jpg')
Image(b'RAW_PNG_DATA...')
Specifying Image(url=...) does not embed the image data, it only generates ``<img>`` tag with a link to the source. This will not work in the qtconsole or offline.
Image(url='https://www.google.fr/images/srpr/logo3w.png')

Aliases

  • IPython.display.Image.__init__