mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-06 01:42:12 +00:00
Some checks failed
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
29 lines
1.3 KiB
C#
29 lines
1.3 KiB
C#
using AIStudio.Tools.Rust;
|
|
|
|
namespace AIStudio.Tools.Services;
|
|
|
|
public sealed partial class RustService
|
|
{
|
|
/// <summary>
|
|
/// Validates and optionally optimizes a local image in the Rust runtime.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The runtime rejects files whose content does not match their extension, so the returned MIME
|
|
/// type always describes the actual bytes.
|
|
/// </remarks>
|
|
/// <param name="path">The absolute path of a PNG, JPEG, or WebP image.</param>
|
|
/// <param name="optimize">Whether the maximum-edge policy and re-encoding are applied.</param>
|
|
/// <param name="token">The cancellation token.</param>
|
|
/// <returns>The prepared image, dimensions, and stable MIME type.</returns>
|
|
public async Task<ImagePrepareResponse> PrepareImageAsync(
|
|
string path,
|
|
bool optimize,
|
|
CancellationToken token = default)
|
|
{
|
|
using var response = await this.http.PostAsJsonAsync("/image/prepare", new { path, optimize }, this.jsonRustSerializerOptions, token);
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
return await response.Content.ReadFromJsonAsync<ImagePrepareResponse>(this.jsonRustSerializerOptions, token)
|
|
?? throw new InvalidDataException("The Rust image preparation returned an empty response.");
|
|
}
|
|
} |