diff --git a/docs/en/Image-Manipulation.md b/docs/en/Image-Manipulation.md index 1050b6005e..e1715722aa 100644 --- a/docs/en/Image-Manipulation.md +++ b/docs/en/Image-Manipulation.md @@ -76,8 +76,8 @@ public interface IImageResizer **Example usage:** ```csharp -var result = await _imageResizer.ResizeAsync( - stream, /* A stream object that represents an image */ +var resizeResult = await _imageResizer.ResizeAsync( + imageStream, /* A stream object that represents an image */ new ImageResizeArgs { Width = 100, @@ -88,6 +88,16 @@ var result = await _imageResizer.ResizeAsync( ); ``` +> If `resizeResult.State` returns 'Done,' it means that the resize operation was successful. However, if it does not return 'Done,' the stream you're using might be corrupt. Therefore, you can perform a check like the one below and assign the correct stream to the main stream. + +```csharp +if (resizeResult.Result is not null && imageStream != resizeResult.Result && resizeResult.Result.CanRead) +{ + await imageStream.DisposeAsync(); + imageStream = resizeResult.Result; +} +``` + > You can use `MimeTypes.Image.Jpeg` constant instead of the `image/jpeg` magic string used in that example. ### ImageResizeArgs @@ -170,12 +180,23 @@ public interface IImageCompressor **Example usage:** ```csharp -var result = await _imageCompressor.CompressAsync( - stream, /* A stream object that represents an image */ +var compressResult = await _imageCompressor.CompressAsync( + imageStream, /* A stream object that represents an image */ mimeType: "image/jpeg" ); ``` +> If `compressResult.State` returns 'Done,' it means that the compress operation was successful. However, if it does not return 'Done,' the stream you're using might be corrupt. Therefore, you can perform a check like the one below and assign the correct stream to the main stream. + +```csharp + +if (compressResult.Result is not null && imageStream != compressResult.Result && compressResult.Result.CanRead) +{ + await imageStream.DisposeAsync(); + imageStream = compressResult.Result; +} +``` + ### ImageCompressResult The `ImageCompressResult` is a generic class that is used to return the result of the image compression operations. It has the following properties: