| Crates.io | i3f |
| lib.rs | i3f |
| version | 0.0.3 |
| created_at | 2025-11-30 13:19:32.735711+00 |
| updated_at | 2025-12-01 05:36:22.22597+00 |
| description | A library for IIIF API, including Image, Presentation. |
| homepage | |
| repository | https://github.com/jefferywang/iiif |
| max_upload_size | |
| id | 1958213 |
| size | 305,969 |
i3f 是一个用 Rust 实现的 IIIF (International Image Interoperability Framework) API 库,支持 IIIF Image API 3.0 和 Presentation API 3.0 规范。
✅ IIIF Image API 3.0 完整支持
full、square、像素坐标和百分比坐标default、color、gray、bitonaljpg、png、gif、webp、tif、jp2、pdfinfo.json 结构支持✅ IIIF Presentation API 3.0 完整支持
✅ 图像处理能力
imageproc 库)image 库内置方法)✅ 存储抽象
在 Cargo.toml 中添加依赖:
[dependencies]
i3f = "*"
use i3f::image::IiifImage;
use url::Url;
let url = Url::parse("https://example.org/image-service/demo.jpg/full/max/0/default.jpg")?;
let image = IiifImage::try_from(url)?;
println!("Identifier: {}", image.identifier);
println!("Region: {}", image.region);
println!("Size: {}", image.size);
println!("Rotation: {}", image.rotation);
println!("Quality: {}", image.quality);
println!("Format: {}", image.format);
use i3f::image::{IiifImage, LocalStorage};
use url::Url;
let url = Url::parse("https://example.org/image-service/demo.jpg/full/max/45/default.jpg")?;
let image = IiifImage::try_from(url)?;
let storage = LocalStorage::new("./fixtures");
let processed_image = image.process(&storage)?;
// 保存处理后的图像
processed_image.save("./output/result.jpg")?;
use i3f::presentation::{Manifest, Canvas, LangMap};
use std::collections::HashMap;
let mut label = LangMap::new();
label.insert("en".to_string(), vec!["My Manifest".to_string()]);
label.insert("zh".to_string(), vec!["我的清单".to_string()]);
let manifest = Manifest {
context: i3f::presentation::Context::presentation_default(),
id: "https://example.org/manifest.json".to_string(),
r#type: "Manifest".to_string(),
label,
items: vec![],
..Default::default()
};
// 序列化为 JSON
let json = serde_json::to_string_pretty(&manifest)?;
println!("{}", json);
image: IIIF Image API 3.0 实现
IiifImage: 图像请求解析和处理Region: 区域裁剪Size: 尺寸调整Rotation: 旋转处理Quality: 质量设置Format: 格式转换ImageInfo: 图像信息结构presentation: IIIF Presentation API 3.0 实现
Collection: 集合结构Manifest: 清单结构Canvas: 画布结构Range: 范围结构Annotation: 注解结构AnnotationPage: 注解页结构storage: 存储抽象
Storage: 存储接口LocalStorage: 本地文件系统存储实现error: 错误类型
IiifError: IIIF 相关错误枚举MIT License
欢迎提交 Issue 和 Pull Request!
i3f is a Rust implementation of the IIIF (International Image Interoperability Framework) API library, supporting IIIF Image API 3.0 and Presentation API 3.0 specifications.
✅ Full IIIF Image API 3.0 Support
full, square, pixel coordinates, and percentage coordinatesdefault, color, gray, bitonaljpg, png, gif, webp, tif, jp2, pdfinfo.json structure support✅ Full IIIF Presentation API 3.0 Support
✅ Image Processing Capabilities
imageproc library)image library built-in methods)✅ Storage Abstraction
Add the dependency to your Cargo.toml:
[dependencies]
i3f = "*"
use i3f::image::IiifImage;
use url::Url;
let url = Url::parse("https://example.org/image-service/demo.jpg/full/max/0/default.jpg")?;
let image = IiifImage::try_from(url)?;
println!("Identifier: {}", image.identifier);
println!("Region: {}", image.region);
println!("Size: {}", image.size);
println!("Rotation: {}", image.rotation);
println!("Quality: {}", image.quality);
println!("Format: {}", image.format);
use i3f::image::{IiifImage, LocalStorage};
use url::Url;
let url = Url::parse("https://example.org/image-service/demo.jpg/full/max/45/default.jpg")?;
let image = IiifImage::try_from(url)?;
let storage = LocalStorage::new("./fixtures");
let processed_image = image.process(&storage)?;
// Save the processed image
processed_image.save("./output/result.jpg")?;
use i3f::presentation::{Manifest, LangMap};
use std::collections::HashMap;
let mut label = LangMap::new();
label.insert("en".to_string(), vec!["My Manifest".to_string()]);
label.insert("zh".to_string(), vec!["我的清单".to_string()]);
let manifest = Manifest {
context: i3f::presentation::Context::presentation_default(),
id: "https://example.org/manifest.json".to_string(),
r#type: "Manifest".to_string(),
label,
items: vec![],
..Default::default()
};
// Serialize to JSON
let json = serde_json::to_string_pretty(&manifest)?;
println!("{}", json);
image: IIIF Image API 3.0 implementation
IiifImage: Image request parsing and processingRegion: Region croppingSize: Size adjustmentRotation: Rotation processingQuality: Quality settingsFormat: Format conversionImageInfo: Image information structurepresentation: IIIF Presentation API 3.0 implementation
Collection: Collection structureManifest: Manifest structureCanvas: Canvas structureRange: Range structureAnnotation: Annotation structureAnnotationPage: Annotation page structurestorage: Storage abstraction
Storage: Storage interfaceLocalStorage: Local file system storage implementationerror: Error types
IiifError: IIIF-related error enumerationMIT License
Issues and Pull Requests are welcome!