Class ImageStreamUtils
Inheritance
ImageStreamUtils
Assembly: SoCore.dll
Syntax
public static class ImageStreamUtils
Methods
FitToAsync(Stream, int, int, CancellationToken)
Declaration
public static Task<Stream> FitToAsync(this Stream imageStream, int width, int height, CancellationToken cancellationToken)
Parameters
Returns
FitToPng(Stream, int, int)
Declaration
public static Stream FitToPng(this Stream imageStream, int width, int height)
Parameters
| Type |
Name |
Description |
| Stream |
imageStream |
|
| int |
width |
|
| int |
height |
|
Returns
FitToPngBytes(Stream, int, int)
Synchronous companion to FitToAsync(Stream, int, int, CancellationToken). Resizes the input image to fit within the
given bounds while preserving aspect ratio, and returns the result as PNG-encoded bytes.
Always re-encodes as PNG regardless of the input format. Returns null if input is null.
Declaration
public static byte[] FitToPngBytes(this Stream imageStream, int width, int height)
Parameters
| Type |
Name |
Description |
| Stream |
imageStream |
|
| int |
width |
|
| int |
height |
|
Returns
GetDefaultMimeTypeAsync(Stream, CancellationToken)
Declaration
public static Task<string> GetDefaultMimeTypeAsync(this Stream imageStream, CancellationToken cancellationToken)
Parameters
Returns
GetNoPhotoPng()
Returns the product-wide "no photo" placeholder (a person silhouette) as PNG bytes,
loaded once from an embedded resource and cached. Used as the visible fallback for the
SrNoPhoto / SrNoPhotoWithBorder strategies on the cross-platform image path,
replacing the GDI+-rendered "NO PHOTO" text image. A fresh copy is returned on every call,
so callers may freely mutate the result without affecting the process-wide cached source.
Declaration
public static byte[] GetNoPhotoPng()
Returns
GetThumbnailPngBytes(Stream, int, int)
Fast thumbnail companion to FitToPngBytes(Stream, int, int). Mirrors the old System.Drawing
GetThumbnailImage path for very small images where speed matters more than high-quality scaling.
Declaration
public static byte[] GetThumbnailPngBytes(this Stream imageStream, int width, int height)
Parameters
| Type |
Name |
Description |
| Stream |
imageStream |
|
| int |
width |
|
| int |
height |
|
Returns
GetTransparentPixelPng()
Returns a 1×1 fully transparent PNG as bytes. Useful as a fallback for missing or invalid
images. A fresh copy is returned on every call, so callers may freely mutate the result
without affecting the process-wide cached source.
Declaration
public static byte[] GetTransparentPixelPng()
Returns