Method RedactToFile
RedactToFile(string, string, ImageRedactionRequest, ImageRedactionOptions, CancellationToken)
Redacts the image at inputPath and writes the
result to outputPath.
public static ImageRedactionReport RedactToFile(string inputPath, string outputPath, ImageRedactionRequest request, ImageRedactionOptions options = null, CancellationToken cancellationToken = default)
Parameters
inputPathstringFile-system path to the source image.
outputPathstringDestination path for the redacted image.
requestImageRedactionRequestWhat to redact.
optionsImageRedactionOptionsOptional redaction options; defaults are used when
null.cancellationTokenCancellationTokenCancellation token.
Returns
- ImageRedactionReport
A report describing what was covered.
Remarks
The output encoding follows the source format, not the extension of
outputPath; check
OutputExtension for what was
written.
Exceptions
- ArgumentException
Thrown when a path is null or whitespace.
- ArgumentNullException
Thrown when
requestis null.- FileNotFoundException
Thrown when
inputPathdoes not exist.- InvalidOperationException
Thrown when the request carries search terms but no OcrEngine.
- ImageLoadingException
Thrown when the image data cannot be decoded.
RedactToFile(Attachment, string, ImageRedactionRequest, ImageRedactionOptions, CancellationToken)
Redacts the image carried by attachment and
writes the result to outputPath.
public static ImageRedactionReport RedactToFile(Attachment attachment, string outputPath, ImageRedactionRequest request, ImageRedactionOptions options = null, CancellationToken cancellationToken = default)
Parameters
attachmentAttachmentThe attachment carrying the source image.
outputPathstringDestination path for the redacted image.
requestImageRedactionRequestWhat to redact.
optionsImageRedactionOptionsOptional redaction options; defaults are used when
null.cancellationTokenCancellationTokenCancellation token.
Returns
- ImageRedactionReport
A report describing what was covered.
Exceptions
- ArgumentException
Thrown when
outputPathis null or whitespace.- ArgumentNullException
Thrown when
attachmentorrequestis null.- NotSupportedException
Thrown when the attachment does not carry a raster image.
- InvalidOperationException
Thrown when the request carries search terms but no OcrEngine.
- ImageLoadingException
Thrown when the image data cannot be decoded.