Image

Add a raster IMAGE (DXF Reference) to the DXF file, the file itself is not embedded into the DXF file, it is always a separated file. The IMAGE entity is like a block reference, you can use it multiple times to add the image on different locations with different scales and rotations. But therefore you need a also a IMAGEDEF entity, see ImageDef. ezdxf creates only images in the xy-plan, you can place images in the 3D space too, but then you have to set the Image.dxf.u_pixel and the Image.dxf.v_pixel vectors by yourself.

Subclass of

ezdxf.entities.DXFGraphic

DXF type

'IMAGE'

Factory function

ezdxf.layouts.BaseLayout.add_image()

Inherited DXF attributes

Common graphical DXF attributes

Required DXF version

DXF R2000 ('AC1015')

Warning

Do not instantiate entity classes by yourself - always use the provided factory functions!

class ezdxf.entities.Image
dxf.insert

Insertion point, lower left corner of the image (3D Point in WCS).

dxf.u_pixel

U-vector of a single pixel (points along the visual bottom of the image, starting at the insertion point) as (x, y, z) tuple

dxf.v_pixel

V-vector of a single pixel (points along the visual left side of the image, starting at the insertion point) as (x, y, z) tuple

dxf.image_size

Image size in pixels as (x, y) tuple

dxf.image_def_handle

Handle to the image definition entity, see ImageDef

dxf.flags

Image.dxf.flags

Value

Description

Image.SHOW_IMAGE

1

Show image

Image.SHOW_WHEN_NOT_ALIGNED

2

Show image when not aligned with screen

Image.USE_CLIPPING_BOUNDARY

4

Use clipping boundary

Image.USE_TRANSPARENCY

8

Transparency is on

dxf.clipping

Clipping state:

0

clipping off

1

clipping on

dxf.brightness

Brightness value (0-100; default = 50)

dxf.contrast

Contrast value (0-100; default = 50)

dxf.fade

Fade value (0-100; default = 0)

dxf.clipping_boundary_type

Clipping boundary type:

1

Rectangular

2

Polygonal

dxf.count_boundary_points

Number of clip boundary vertices, maintained by ezdxf.

dxf.clip_mode

Clip mode (DXF R2010):

0

Outside

1

Inside

boundary_path

A list of vertices as pixel coordinates, Two vertices describe a rectangle, lower left corner is (-0.5, -0.5) and upper right corner is (ImageSizeX-0.5, ImageSizeY-0.5), more than two vertices is a polygon as clipping path. All vertices as pixel coordinates. (read/write)

reset_boundary_path() → None

Reset boundary path to the default rectangle [(-0.5, -0.5), (ImageSizeX-0.5, ImageSizeY-0.5)].

set_boundary_path(vertices: Iterable[Vertex]) → None

Set boundary path to vertices. Two vertices describe a rectangle (lower left and upper right corner), more than two vertices is a polygon as clipping path.

get_image_def() → ImageDef

Returns the associated IMAGEDEF entity. see ImageDef.