Skip to content

Commit

Permalink
Add new constructors to AverageHash struct
Browse files Browse the repository at this point in the history
  • Loading branch information
takebayashi committed Jan 3, 2024
1 parent 0074eda commit ec5c5eb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ pub struct AverageHash<'a> {
}

impl<'a> AverageHash<'a> {
/// Creates a new `AverageHasher` with default parameters.
pub fn new() -> Self {
AverageHash::default()
}

/// Creates a new `AverageHasher` with the specified parameters.
pub fn with_op(op: &'a ImageOp) -> Self {
AverageHash { op }
}

/// Calculates average hash (aHash) of the image and returns as a hex string.
pub fn hash(&self, image: &image::DynamicImage) -> String {
let bits = average_hash(image, self.op);
Expand Down

0 comments on commit ec5c5eb

Please sign in to comment.