Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordImage

OfficeIMO.Word

Namespace
OfficeIMO.Word
Assembly
OfficeIMO.Word
Source revision
0eef6a5756b9 with working tree changes

Represents an image contained in a WordDocument and provides functionality to insert and manipulate pictures.

Inheritance

Usage

Explore 16 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Methods

public WordImage Clone(WordParagraph paragraph) #

Creates a copy of this image and appends it to the specified paragraph. The cloned image retains its native representation and establishes relationships in the destination story.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
The paragraph to append the cloned image to.

Returns

WordImage The newly created WordImage instance.
public Stream OpenRead() #

Retrieves the image data as a stream without loading the entire image into memory.

Returns

Stream A Stream for reading the image bytes.
public void Remove() #

Remove image from a Word Document

Save 2 overloads
public void Save(string fileToSave) #

Extract image from Word Document and save it to file

Parameters

fileToSave string required
public void Save(Stream stream) #

Saves the image to a caller-owned stream.

Parameters

stream System.IO.Stream required
SaveAsync 2 overloads
public async Task SaveAsync(string path, CancellationToken cancellationToken = default) #

Saves the image to a file asynchronously.

Parameters

path string required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public async Task SaveAsync(Stream stream, CancellationToken cancellationToken = default) #

Saves the image to a caller-owned stream asynchronously.

Parameters

stream System.IO.Stream required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public WordImage SetCrop(OfficeLength? left, OfficeLength? top, OfficeLength? right, OfficeLength? bottom) #

Applies all four physical source crops together, validating the frame and anchor before changing the image.

Parameters

left OfficeIMO.OfficeLength? required
top OfficeIMO.OfficeLength? required
right OfficeIMO.OfficeLength? required
bottom OfficeIMO.OfficeLength? required

Returns

WordImage
public WordImage SetMaximumWidth(OfficeLength width) #

Clamps the displayed width while retaining the image's other authoring properties.

Parameters

width OfficeIMO.OfficeLength required

Returns

WordImage
public byte[] ToBytes() #

Retrieves the image data as a byte array.

Returns

byte[] Bytes representing the image.
public MemoryStream ToStream() #

Returns the image bytes in a new stream positioned at the beginning.

Returns

MemoryStream

Properties

public WordParagraph Paragraph { get; } #

Gets the paragraph containing this image occurrence.

public int? Transparency { get; set; } #

Gets or sets the image transparency percentage (0-100).

public WordImageTextWrapping? WrapText { get; set; } #

Gets or sets the image's wrap text.

public uint ZOrder { get; set; } #

Gets or sets the native DrawingML anchor stacking order.

public WordImageFillMode FillMode { get; set; } #

Gets or sets how the image should fill its bounding box. Default is Stretch.

public bool? UseLocalDpi { get; set; } #

Specifies whether to use the image's local DPI setting when rendering.

public bool? PreferRelativeResize { get; set; } #

Indicates whether resizing should be relative to the original size.

public bool? NoChangeAspect { get; set; } #

Gets or sets whether the aspect ratio is locked.

public bool? NoCrop { get; set; } #

Gets or sets whether the image cannot be cropped.

public bool? NoMove { get; set; } #

Gets or sets whether the image is locked from moving.

public bool? NoResize { get; set; } #

Gets or sets whether the image cannot be resized.

public bool? NoRot { get; set; } #

Gets or sets whether the image cannot be rotated.

public bool? NoSelect { get; set; } #

Gets or sets whether the image cannot be selected.

public OfficeLength? CropTop { get; set; } #

Gets or sets the crop from the top as a length of the original image height, before displayed scaling.

Exceptions

  • InvalidOperationException – The embedded source size or floating anchor position cannot be resolved without pagination.
  • ArgumentOutOfRangeException – The crop is not finite, removes the entire source area, or overflows the frame or anchor range.
public OfficeLength? CropBottom { get; set; } #

Gets or sets the crop from the bottom as a length of the original image height, before displayed scaling.

Exceptions

  • InvalidOperationException – The embedded source size or floating anchor position cannot be resolved without pagination.
  • ArgumentOutOfRangeException – The crop is not finite, removes the entire source area, or overflows the frame or anchor range.
public OfficeLength? CropLeft { get; set; } #

Gets or sets the crop from the left as a length of the original image width, before displayed scaling.

Exceptions

  • InvalidOperationException – The embedded source size or floating anchor position cannot be resolved without pagination.
  • ArgumentOutOfRangeException – The crop is not finite, removes the entire source area, or overflows the frame or anchor range.
public OfficeLength? CropRight { get; set; } #

Gets or sets the crop from the right as a length of the original image width, before displayed scaling.

Exceptions

  • InvalidOperationException – The embedded source size or floating anchor position cannot be resolved without pagination.
  • ArgumentOutOfRangeException – The crop is not finite, removes the entire source area, or overflows the frame or anchor range.
public double? CropTopRatio { get; set; } #

Gets or sets the Top source crop as a fraction of the original image; one means its full dimension.

public double? CropBottomRatio { get; set; } #

Gets or sets the Bottom source crop as a fraction of the original image; one means its full dimension.

public double? CropLeftRatio { get; set; } #

Gets or sets the Left source crop as a fraction of the original image; one means its full dimension.

public double? CropRightRatio { get; set; } #

Gets or sets the Right source crop as a fraction of the original image; one means its full dimension.

public WordImageCompressionQuality? CompressionQuality { get; set; } #

Gets or sets the compression quality for embedded images.

public string? RelationshipId { get; } #

Gets the relationship id of the embedded image.

public string? ExternalRelationshipId { get; } #

Gets the relationship id of an externally linked image, if any.

public bool IsExternal { get; } #

Indicates whether the image is stored outside the package.

public string ContentType { get; } #

Gets the content type of the embedded image part, or an empty string for external images.

public Uri? ExternalUri { get; } #

Gets the URI of the externally linked image.

public string FilePath { get; set; } #

Gets or sets the file path or name for the image.

public string? FileName { get; set; } #

Get or sets the image's file name

public string? AltText { get; set; } #

Gets or sets the image's alternative text.

public string? Title { get; set; } #

Gets or sets the image's title.

public bool? Hidden { get; set; } #

Specifies whether the picture is hidden.

public OfficePresetShapeType? Shape { get; set; } #

Gets or sets the shape type used to display the image.

public WordImageBlackWhiteMode? BlackWhiteMode { get; set; } #

Microsoft Office does not seem to fully support this attribute, and ignores this setting. More information: http://officeopenxml.com/drwSp-SpPr.php

public bool? VerticalFlip { get; set; } #

Gets or sets whether the image is vertically flipped.

public bool? HorizontalFlip { get; set; } #

Gets or sets whether the image is horizontally flipped.

public int? Rotation { get; set; } #

Gets or sets the image rotation in degrees.

public int? FixedOpacity { get; set; } #

Sets a fixed opacity value for the image.

public OfficeColor? AlphaInversionColor { get; set; } #

Gets or sets the alpha inversion color.

public int? BlackWhiteThreshold { get; set; } #

Gets or sets the threshold for black and white effect.

public OfficeLength? BlurRadius { get; set; } #

Gets or sets the image blur radius.

public bool? BlurGrow { get; set; } #

Gets or sets whether the blur grows the image's bounds.

public OfficeColor? ColorChangeFrom { get; set; } #

Gets or sets the source color to change from.

public OfficeColor? ColorChangeTo { get; set; } #

Gets or sets the target color to change to.

public OfficeColor? ColorReplacement { get; set; } #

Gets or sets a color replacement.

public OfficeColor? DuotoneColor1 { get; set; } #

Gets or sets the first duotone color.

public OfficeColor? DuotoneColor2 { get; set; } #

Gets or sets the second duotone color.

public bool? GrayScale { get; set; } #

Gets or sets whether the image is displayed in grayscale.

public int? LuminanceBrightness { get; set; } #

Gets or sets the brightness adjustment.

public int? LuminanceContrast { get; set; } #

Gets or sets the contrast adjustment.

public int? TintAmount { get; set; } #

Gets or sets the tint amount.

public int? TintHue { get; set; } #

Gets or sets the tint hue.

public OfficeLength? Width { get; set; } #

Gets or sets the displayed image width. Null means no width is stored.

public OfficeLength? Height { get; set; } #

Gets or sets the displayed image height. Null means no height is stored.

public WordHorizontalRelativePosition HorizontalPositionRelativeFrom { get; set; } #

Gets or sets the horizontal reference used by a floating image.

public OfficeLength? HorizontalPositionOffset { get; set; } #

Gets or sets the horizontal image offset. Inline images have no page offset and return null.

public WordVerticalRelativePosition VerticalPositionRelativeFrom { get; set; } #

Gets or sets the vertical reference used by a floating image.

public OfficeLength? VerticalPositionOffset { get; set; } #

Gets or sets the vertical image offset. Inline images have no page offset and return null.