OfficeImageMetadata
OfficeIMO.Drawing
Portable image metadata with typed Exif edits and independently owned profile bytes.
Inheritance
- object
- OfficeImageMetadata
Remarks
Metadata edits do not apply ICC color transformations to image pixels. Use OfficeImageMetadata.Apply to replace supported container metadata without recompressing image data.
Usage
Explore 10 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 5
Accepted by parameters 5
Constructors
public OfficeImageMetadata() #Methods
public static byte[] Apply(byte[] encodedBytes, OfficeImageMetadata metadata, CancellationToken cancellationToken = default) #Replaces supported primary-image profiles and density without recompressing image pixels.
Parameters
- encodedBytes byte[]
- metadata OfficeIMO.Drawing.OfficeImageMetadata
- cancellationToken System.Threading.CancellationToken = default
Returns
byte[]public OfficeRasterEncodingResult ApplyForEncoding(byte[] encodedBytes, OfficeRasterEncodingOptions? options = null, long maximumEncodedBytes = 134217728, CancellationToken cancellationToken = default) #Projects and applies this metadata to an already encoded managed raster container.
Parameters
- encodedBytes byte[]
- A complete encoded raster container, including externally encoded GIF or APNG animation.
- options OfficeIMO.Drawing.OfficeRasterEncodingOptions? = null
- Resolution override and density-writing policy only; compression settings cannot alter already encoded pixels. The shared write switch suppresses native and Exif density. PNG's switch suppresses pHYs, and JPEG's switch suppresses JFIF; both retain supplied Exif density. TIFF and WebP store density in Exif, so their switches suppress those density tags.
- maximumEncodedBytes long = 134217728
- Positive ceiling for the complete rewritten container, at most 128 MiB.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation observed during inspection and rewriting.
Returns
OfficeRasterEncodingResult Owned rewritten bytes, the applied projection, and unsupported supplied profile-family omissions.public void ClearExif() #Removes the entire Exif profile, including opaque and thumbnail data.
public OfficeImageMetadata Clone() #Creates an independent copy of profiles, typed fields, pending edits, and TIFF preservation constraints.
Returns
OfficeImageMetadatapublic byte[]? EncodeExifProfile() #Returns a classic TIFF profile containing the current edits, or null when Exif is absent.
Returns
byte[]?public byte[]? EncodeExifProfile(CancellationToken cancellationToken) #Encodes classic TIFF Exif metadata while observing cancellation during directory and value processing.
Parameters
- cancellationToken System.Threading.CancellationToken
Returns
byte[]?public OfficeExifValue? GetExifValue(OfficeExifTag tag) #Returns a typed field, or null when absent.
Parameters
- tag OfficeIMO.Drawing.OfficeExifTag
Returns
OfficeExifValue?public static OfficeImageMetadataInspection Inspect(byte[] encodedBytes, OfficeImageMetadataInspectionOptions? options = null, CancellationToken cancellationToken = default) #Inspects supported encoded image metadata without editing the input or decoding pixels.
Parameters
- encodedBytes byte[]
- options OfficeIMO.Drawing.OfficeImageMetadataInspectionOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Exceptions
OfficeInspectionResourceLimitException– The configured metadata input-byte ceiling was exceeded.
public static OfficeImageMetadataInspection InspectExifProfile(byte[] profile, OfficeImageMetadataInspectionOptions? options = null, CancellationToken cancellationToken = default) #Inspects a standalone classic TIFF Exif profile, optionally including JPEG Exif framing.
Parameters
- profile byte[]
- options OfficeIMO.Drawing.OfficeImageMetadataInspectionOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Exceptions
OfficeInspectionResourceLimitException– The configured metadata input-byte ceiling was exceeded.
public static OfficeImageMetadata ParseExifProfile(byte[] profile) #Reads a classic TIFF Exif profile or a JPEG-prefixed Exif profile.
Parameters
- profile byte[]
Returns
OfficeImageMetadatapublic static OfficeImageMetadata ParseExifProfile(byte[] profile, CancellationToken cancellationToken) #Reads classic TIFF or JPEG-prefixed Exif metadata while observing cancellation.
Parameters
- profile byte[]
- cancellationToken System.Threading.CancellationToken
Returns
OfficeImageMetadatapublic OfficeImageMetadata PrepareForEncoding(OfficeImageFormat format, out OfficeImageMetadataProfileKinds omittedProfiles) #Creates an independent metadata copy containing only profile families carried by the destination format.
Parameters
- format OfficeIMO.Drawing.OfficeImageFormat
- The destination image container.
- omittedProfiles OfficeIMO.Drawing.OfficeImageMetadataProfileKinds
- Profile families present in this metadata that the destination cannot carry.
Returns
OfficeImageMetadata An independent metadata copy suitable for the destination's supported profile families.public static OfficeImageMetadata Read(byte[] encodedBytes, CancellationToken cancellationToken = default) #Reads image profiles and physical resolution from a supported encoded image.
Parameters
- encodedBytes byte[]
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeImageMetadatapublic static OfficeImageMetadataRemovalResult Remove(byte[] encodedBytes, OfficeImageMetadataProfileKinds kinds, CancellationToken cancellationToken = default) #Removes selected supported profile families while preserving encoded image payloads, frame timing, and TIFF pages.
Parameters
- encodedBytes byte[]
- kinds OfficeIMO.Drawing.OfficeImageMetadataProfileKinds
- cancellationToken System.Threading.CancellationToken = default
public bool RemoveExifValue(OfficeExifTag tag) #Removes a field and returns whether it was present.
Parameters
- tag OfficeIMO.Drawing.OfficeExifTag
Returns
boolpublic void SetExifValue(OfficeExifTag tag, object value) #Sets an Exif scalar, text, rational, or typed array using the tag's representation.
Parameters
- tag OfficeIMO.Drawing.OfficeExifTag
- value object
Inherited Methods
Properties
public double HorizontalResolution { get; set; } #Horizontal resolution in OfficeImageMetadata.ResolutionUnits.
public double VerticalResolution { get; set; } #Vertical resolution in OfficeImageMetadata.ResolutionUnits.
public OfficeImageResolutionUnit ResolutionUnits { get; set; } #The unit for both resolution values.
public OfficeImageResolution Resolution { get; set; } #The authoritative native density or unitless aspect ratio, suitable for encoder overrides.
public double? PhysicalDpiX { get; } #Horizontal physical resolution in dots per inch, or null for a unitless aspect ratio.
public double? PhysicalDpiY { get; } #Vertical physical resolution in dots per inch, or null for a unitless aspect ratio.
public bool HasExifProfile { get; } #Whether any Exif fields or an opaque Exif profile are present.
public bool RequiresOriginalTiffContainer { get; } #Whether TIFF-relative opaque fields require their original TIFF container for safe preservation.
public byte[]? ExifProfile { get; set; } #Classic TIFF Exif profile without a JPEG Exif prefix. Setting a profile replaces all pending Exif edits.
public byte[]? XmpProfile { get; set; } #XMP XML packet, excluding container framing. Profile arrays are copied.
public byte[]? IccProfile { get; set; } #ICC profile bytes. Profile arrays are copied.
public byte[]? IptcProfile { get; set; } #IPTC IIM data, excluding Photoshop resource framing. Profile arrays are copied.
public IReadOnlyList<OfficeExifValue> ExifValues { get; } #Current Exif values from the image, camera, GPS, and interoperability directories.