1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! # figif-core
//!
//! A Rust library for GIF frame analysis and manipulation with a plugin architecture.
//!
//! figif-core provides tools for:
//! - **Duplicate Detection**: Identify similar/duplicate frames using perceptual hashing
//! - **Segment Analysis**: Group consecutive similar frames into logical segments
//! - **Timing Control**: Modify frame delays to speed up, slow down, or collapse segments
//! - **Export**: Re-encode GIFs with applied modifications
//!
//! ## Quick Start
//!
//! ```ignore
//! use figif_core::prelude::*;
//!
//! // Create analyzer with default settings (uses dHash)
//! let figif = Figif::new();
//!
//! // Analyze a GIF file
//! let analysis = figif.analyze_file("demo.gif")?;
//!
//! // Inspect detected segments
//! for segment in &analysis.segments {
//! println!(
//! "Segment {}: {} frames, {}ms, static={}",
//! segment.id,
//! segment.frame_count(),
//! segment.duration_ms(),
//! segment.is_static
//! );
//! }
//!
//! // Cap all pause segments to max 300ms
//! let ops = analysis.pauses().cap(300);
//!
//! // Export with a lossless encoder
//! let encoder = StandardEncoder::new();
//! analysis.export_to_file(&encoder, &ops, "output.gif", &EncodeConfig::default())?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ## Fluent Selector API
//!
//! The selector API provides chainable, ergonomic control over segment operations:
//!
//! ```ignore
//! use figif_core::prelude::*;
//!
//! let analysis = Figif::new().analyze_file("demo.gif")?;
//!
//! // Cap all pauses to 300ms
//! let ops = analysis.pauses().cap(300);
//!
//! // Collapse only long pauses (> 500ms) to 200ms
//! let ops = analysis.pauses().longer_than(500).collapse(200);
//!
//! // Remove pauses longer than 1 second
//! let ops = analysis.pauses().longer_than(1000).remove();
//!
//! // Speed up motion segments by 1.5x
//! let ops = analysis.motion().speed_up(1.5);
//!
//! // Combine operations: cap long pauses AND speed up motion
//! let ops = analysis.pauses().longer_than(500).cap(300)
//! .merge(&analysis.motion().speed_up(1.2));
//!
//! // Get statistics
//! println!("Pause count: {}", analysis.pauses().count());
//! println!("Pause duration: {}ms", analysis.pauses().total_duration_ms());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ## Using Different Hashers
//!
//! ```ignore
//! use figif_core::{Figif, hashers::{PHasher, BlockHasher}};
//!
//! // Use pHash for more robust matching
//! let figif = Figif::new()
//! .with_hasher(PHasher::new())
//! .similarity_threshold(8);
//!
//! // Or use BlockHash
//! let figif = Figif::new()
//! .with_hasher(BlockHasher::with_size(16, 16));
//! ```
//!
//! ## Lossy Encoding (requires `lossy` feature)
//!
//! ```ignore
//! #[cfg(feature = "lossy")]
//! {
//! use figif_core::encoders::GifskiEncoder;
//! use figif_core::EncodeConfig;
//!
//! let encoder = GifskiEncoder::with_quality(85);
//! let config = EncodeConfig::new()
//! .with_width(480)
//! .with_lossy_quality(80);
//!
//! let bytes = analysis.export(&encoder, &ops, &config)?;
//! }
//! ```
//!
//! ## Feature Flags
//!
//! - `parallel` (default): Enable parallel frame hashing using rayon
//! - `lossy`: Enable GifskiEncoder for high-quality lossy compression
//!
//! ## Plugin Architecture
//!
//! figif-core is designed to be extensible. You can implement custom:
//!
//! - **Hashers**: Implement [`traits::FrameHasher`] for custom duplicate detection
//! - **Decoders**: Implement [`traits::GifDecoder`] for custom loading
//! - **Encoders**: Implement [`traits::GifEncoder`] for custom output formats
//! - **Similarity Metrics**: Implement [`traits::SimilarityMetric`] for custom comparison
// Re-export main types at crate root for convenience
pub use ;
pub use ;
pub use ;
pub use ;
/// Prelude module for convenient imports.
///
/// ```ignore
/// use figif_core::prelude::*;
/// ```