WordImage
OfficeIMO.Word
Represents an image contained in a WordDocument and provides functionality to insert and manipulate pictures.
Inheritance
- WordElement
- WordImage
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.
Returned or exposed by 16
- Method WordDocument.AddImage
- Method WordDocument.AddImageAsync
- Property WordDocument.Images
- Property WordFooter.Images
- Property WordFormattedRun.Image
- Method WordHeader.AddImage
- Property WordHeader.Images
- Property WordHeaderFooter.Images
- Method WordImage.Clone
- Method WordImage.SetCrop
- Method WordImage.SetMaximumWidth
- Method WordParagraph.AddImage
- Property WordParagraph.Image
- Property WordPictureControl.Image
- Method WordSection.AddImage
- Property WordSection.Images
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
- The paragraph to append the cloned image to.
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 async Task SaveAsync(string path, CancellationToken cancellationToken = default) #Saves the image to a file asynchronously.
Parameters
- path string
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic async Task SaveAsync(Stream stream, CancellationToken cancellationToken = default) #Saves the image to a caller-owned stream asynchronously.
Parameters
- stream System.IO.Stream
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic 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?
- top OfficeIMO.OfficeLength?
- right OfficeIMO.OfficeLength?
- bottom OfficeIMO.OfficeLength?
Returns
WordImagepublic WordImage SetMaximumWidth(OfficeLength width) #Clamps the displayed width while retaining the image's other authoring properties.
Parameters
- width OfficeIMO.OfficeLength
Returns
WordImagepublic 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
MemoryStreamInherited Methods
Properties
public WordParagraph Paragraph { get; } #Gets the paragraph containing this image occurrence.
public Uri? Hyperlink { get; set; } #Gets or sets the external hyperlink wrapping this image. Null removes the link.
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 string FilePath { get; set; } #Gets or sets the file path or name for the image.
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? 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 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.