reading exif-proof of concept.

This commit is contained in:
Micha Glave 2020-06-17 11:08:44 +02:00
parent 13bc6a165e
commit e493d37860
6 changed files with 75 additions and 25 deletions

25
.gitignore vendored
View File

@ -15,27 +15,7 @@ Cargo.lock
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
.idea/
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
@ -53,9 +33,6 @@ Cargo.lock
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws

BIN
BlueSquare.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
Canon_40D.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

15
Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "curators"
version = "0.1.0"
authors = ["Micha Glave <mig@xilab.net>"]
edition = "2018"
exclude = [".travis.yml", ".gitignore", "test-data/**"]
description = "Image Gallery. Defined by plain files."
[dependencies]
toml = "0.5"
structopt = "0.3"
#exempi = "2.5.0"
strum = "0.18.0"
strum_macros = "0.18.0"
kamadak-exif = "0.5"

View File

@ -1,3 +1,10 @@
# curators
Image Gallery. Defined by plain files.
Image Gallery. Defined by plain files.
## Goal:
Image management for multiple (competing) users. Purely file-based, non-destructive, based on standards (as much as possible). Using
* [Exif](https://de.wikipedia.org/wiki/Exchangeable_Image_File_Format)
* [IPTC](https://de.wikipedia.org/wiki/IPTC-IIM-Standard)
* [XMP](https://de.wikipedia.org/wiki/Extensible_Metadata_Platform)

51
src/main.rs Normal file
View File

@ -0,0 +1,51 @@
extern crate strum;
use structopt::StructOpt;
use strum_macros::EnumString;
#[derive(EnumString, Debug)]
enum Cmd {
#[strum(serialize = "read", serialize = "r")]
Read,
#[strum(
serialize = "write",
serialize = "w",
serialize = "set",
serialize = "s"
)]
Write,
}
#[derive(Debug, StructOpt)]
#[structopt(name = "curators", about = "An image meta-data handling tool.")]
struct Opt {
/// image-file to work with.
image_file: String,
/// operation
cmd: Option<Cmd>,
/// Property to handle.
property: Option<String>,
}
fn main() {
let opt = Opt::from_args();
println!("{:?}", opt);
match std::fs::File::open(&opt.image_file) {
Ok(file) => {
let mut bufreader = std::io::BufReader::new(&file);
let exifreader = exif::Reader::new();
match exifreader.read_from_container(&mut bufreader) {
Ok(exif) => {
for f in exif.fields() {
println!("{}: {}", f.tag, f.display_value().with_unit(&exif));
}
}
Err(e) => println!("{:?}", e),
}
}
Err(e) => println!("{:?}", e),
}
}