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
//! Error types for the GeoTIFF library.
#![allow(dead_code)]
use thiserror::Error;
/// Result type alias for GeoTIFF operations.
pub type Result<T> = std::result::Result<T, GeoTiffError>;
/// Errors that can occur when reading or writing GeoTIFF files.
#[derive(Debug, Error)]
pub enum GeoTiffError {
/// I/O error from the underlying file system.
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
/// The file is not a valid TIFF file (bad magic number or byte order).
#[error("Invalid TIFF file: {0}")]
InvalidTiff(String),
/// An IFD (Image File Directory) entry is malformed.
#[error("Invalid IFD entry: {0}")]
InvalidIfd(String),
/// A required TIFF tag is missing.
#[error("Missing required tag: {tag} ({code})")]
MissingTag {
/// Human-readable tag name
tag: &'static str,
/// Numeric TIFF tag code
code: u16,
},
/// A tag has an unexpected or unsupported value.
#[error("Unsupported tag value for {tag}: {value}")]
UnsupportedTagValue {
/// Human-readable tag name
tag: &'static str,
/// The unsupported value
value: u64,
},
/// Compression or decompression failed.
#[error("Compression error ({codec}): {message}")]
CompressionError {
/// Name of the codec
codec: &'static str,
/// Description of the error
message: String,
},
/// The requested compression format is not supported.
#[error("Unsupported compression: {0}")]
UnsupportedCompression(u16),
/// The sample format or bit depth is not supported.
#[error("Unsupported sample format: {bits_per_sample} bits, format={sample_format}")]
UnsupportedSampleFormat {
/// Bits per sample value
bits_per_sample: u16,
/// TIFF SampleFormat tag value
sample_format: u16,
},
/// Image dimensions are zero or otherwise invalid.
#[error("Invalid image dimensions: {width}x{height}x{bands}")]
InvalidDimensions {
/// Width in pixels
width: u32,
/// Height in pixels
height: u32,
/// Number of bands/samples
bands: u16,
},
/// Attempt to read a band index that doesn't exist.
#[error("Band index {index} out of range (file has {bands} bands)")]
BandOutOfRange {
/// Requested band index
index: usize,
/// Available band count
bands: usize,
},
/// Tile or strip data is truncated or corrupt.
#[error("Corrupt image data at {location}: {message}")]
CorruptData {
/// Description of where the corruption was found
location: String,
/// Details of the issue
message: String,
},
/// GeoKey directory is invalid or references unknown keys.
#[error("Invalid GeoKey directory: {0}")]
InvalidGeoKey(String),
/// Buffer size mismatch during write.
#[error("Data size mismatch: expected {expected} samples, got {actual}")]
DataSizeMismatch {
/// Expected number of samples
expected: usize,
/// Actual number of samples provided
actual: usize,
},
}