Add thumbnail endpoint with size options

This commit is contained in:
Joakim Hulthe
2026-04-06 08:17:34 +00:00
parent 1e38963ff6
commit 15d67f5667
3 changed files with 127 additions and 1 deletions

50
examples/thumbnail.rs Normal file
View File

@@ -0,0 +1,50 @@
//! Example: Download asset thumbnails
use immich_sdk::Client;
use immich_sdk::models::AssetMediaSize;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client
let client = Client::from_url("https://immich.example.com")?.with_api_key("your-api-key");
// Asset ID to download thumbnail for
let asset_id = "your-asset-id-here".parse()?;
// Download thumbnail (small size, default)
println!("Downloading thumbnail...");
let thumbnail = client
.assets()
.thumbnail(asset_id)
.size(AssetMediaSize::Thumbnail)
.execute()
.await?;
fs::write("/path/to/output/thumbnail.jpg", &thumbnail)?;
println!("Saved thumbnail: {} bytes", thumbnail.len());
// Download preview (medium size)
let preview = client
.assets()
.thumbnail(asset_id)
.size(AssetMediaSize::Preview)
.execute()
.await?;
fs::write("/path/to/output/preview.jpg", &preview)?;
println!("Saved preview: {} bytes", preview.len());
// Download fullsize
let fullsize = client
.assets()
.thumbnail(asset_id)
.size(AssetMediaSize::Fullsize)
.execute()
.await?;
fs::write("/path/to/output/fullsize.jpg", &fullsize)?;
println!("Saved fullsize: {} bytes", fullsize.len());
Ok(())
}