Skip to content

Commit

Permalink
fixed typos, added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremiah-Griffin committed Jul 12, 2022
1 parent 4c88a1c commit e1a5de7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tiff_tags_nightly"
version = "1.1.0"
version = "1.1.1"
edition = "2021"
license = "MIT"
keywords = ["image", "metadata", "exif", "TIFF", "tags"]
Expand Down
19 changes: 10 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{
(18246, "Image.Rating" ),
(18249, "Image.RatingPercent" ),
(32781, "ImageID" ),
(32932, "Wang Annotation" ),
(32932, "WangAnnotation" ),
(33421, "CFARepeatPatternDim" ),
(33422, "CFAPattern" ),
(33423, "BatteryLevel" ),
Expand All @@ -117,7 +117,7 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{
(33449, "MD_SampleInfo" ),
(33450, "MD_PrepDate" ),
(33451, "MD_PrepTime" ),
(33452, "MD_ FileUnits" ),
(33452, "MD_FileUnits" ),
(33550, "ModelPixelScaleTag" ),
(33723, "IPTC/NAA" ),
(33918, "INGR_Packet_Data_Tag" ),
Expand Down Expand Up @@ -213,7 +213,7 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{
(40962, "PixelXDimension" ),
(40963, "PixelYDimension" ),
(40964, "RelatedSoundFile" ),
(40965, "Interoperability IFD" ),
(40965, "InteroperabilityIFD" ),
(41483, "FlashEnergy" ),
(41484, "SpatialFrequencyResponse" ),
(41486, "FocalPlaneXResolution" ),
Expand Down Expand Up @@ -306,7 +306,7 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{
(50779, "CalibrationIlluminant2" ),
(50780, "BestQualityScale" ),
(50781, "RawDataUniqueID" ),
(50784, "Alias Layer Metadata" ),
(50784, "AliasLayerMetadata" ),
(50827, "OriginalRawFileName" ),
(50828, "OriginalRawFileData" ),
(50829, "ActiveArea" ),
Expand Down Expand Up @@ -364,7 +364,9 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{




///Given a u16 id number, return either its name or None if the tag is not registered.
///Note that this function will return None if multiple tags are registered, as this is technically not against the spec.
///However, no duplicates tags currently are registered according to the source used.
pub fn get_name(tag: impl Into<u16>) -> Option<String>{
let tag = tag.into();
let iter = TAG_MAP.iter();
Expand All @@ -374,12 +376,13 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{
match kvp.len() {
0 => None,
1 => Some(kvp.pop().unwrap().to_owned().1.to_string()),
//>1 returns no error as it is not against the spec for a registered tag to have multiple names.
//in which case, you're probably better off with no value rather than multiple.
_ => None
}
}

///Given the exact name of a tag, return either its u16 ID or None if it is not registered.
///Note that this function will return None if multiple tags are registered, as this is technically not against the spec.
///However, no duplicates tags currently are registered according to the source used.
pub fn get_id(name: impl Into<String>) -> Option<u16>{

let name = name.into();
Expand All @@ -389,8 +392,6 @@ static TAG_MAP: LazyLock<BTreeSet<(u16, &'static str)>> = LazyLock::new(||{
match kvp.len() {
0 => None,
1 => Some(kvp.pop().unwrap().to_owned().0),
//>1 returns no error as it is not against the spec for a registered tag to have multiple names.
//in which case, you're probably better off with no value rather than multiple.
_ => None
}
}
Expand Down

0 comments on commit e1a5de7

Please sign in to comment.