Implement comprehensive metadata extraction for raster images with
EXIF support and display in the right panel.
New features:
- Extract basic metadata (filename, format, resolution, file size, color type)
- Parse EXIF data (camera, date, exposure, aperture, ISO, focal length, GPS)
- Display metadata in collapsible right panel (toggle with 'i' key)
- Auto-refresh metadata on document navigation
Changes by file:
Cargo.toml, Cargo.lock:
- Add kamadak-exif dependency for EXIF parsing
i18n/en/noctua.ftl:
- Add translation strings for all metadata labels
src/app/document/meta.rs:
- New module for metadata types (BasicMeta, ExifMeta, DocumentMeta)
- Extraction logic with EXIF parsing via kamadak-exif
- Helper methods for formatted display (resolution, file size, camera, GPS)
src/app/document/mod.rs:
- Re-export meta module
src/app/document/{raster,vector,portable}.rs:
- Add extract_metadata() method stubs (full impl for raster)
src/app/document/file.rs:
- Reset metadata on document change
src/app/message.rs:
- Add ToggleRightPanel and RefreshMetadata messages
src/app/model.rs:
- Add metadata: Option<DocumentMeta> field
- Add show_right_panel: bool field
src/app/update.rs:
- Handle panel toggle and metadata refresh
- Auto-refresh metadata on navigation when panel visible
src/app/view/panels.rs:
- Implement right_panel() with metadata display
- Conditional sections for basic info and EXIF data
src/app/view/canvas.rs:
- Integrate right panel into layout"
This commit is contained in:
parent
6623a12632
commit
823dfe9fa2
14 changed files with 616 additions and 153 deletions
|
|
@ -91,6 +91,8 @@ fn load_document_into_model(model: &mut AppModel, path: &Path) {
|
|||
match open_document(path.to_path_buf()) {
|
||||
Ok(doc) => {
|
||||
model.document = Some(doc);
|
||||
// Reset cached metadata so it gets reloaded when panel is visible.
|
||||
model.metadata = None;
|
||||
model.current_path = Some(path.to_path_buf());
|
||||
model.clear_error();
|
||||
|
||||
|
|
@ -182,3 +184,17 @@ pub fn navigate_prev(model: &mut AppModel) {
|
|||
load_document_into_model(model, &path);
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// File metadata helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Retrieve the file size in bytes. Returns 0 if the file cannot be accessed.
|
||||
pub fn file_size(path: &Path) -> u64 {
|
||||
fs::metadata(path).map(|m| m.len()).unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Read raw bytes from a file for metadata extraction (e.g., EXIF).
|
||||
/// Returns None if the file cannot be read.
|
||||
pub fn read_file_bytes(path: &Path) -> Option<Vec<u8>> {
|
||||
fs::read(path).ok()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue