Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65bc24d5d9 | ||
|
|
7fc75f194a | ||
|
|
7679be19c1 | ||
|
|
0e9f8e3b5b | ||
|
|
c900129f2c | ||
|
|
61234c0005 | ||
|
|
1416af1018 | ||
|
|
87d652ae5e | ||
|
|
b5a78fbec4 | ||
|
|
30640d50ff | ||
|
|
b87770225f |
No files matched your search
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust: ["1.48", stable, beta, nightly]
|
||||
rust: ["1.61", stable, beta, nightly]
|
||||
command: [build, test]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: test
|
||||
run: >
|
||||
cargo test --tests --benches --no-default-features --features "$FEATURES"
|
||||
if: ${{ matrix.rust != '1.48' }}
|
||||
if: ${{ matrix.rust != '1.61' }}
|
||||
env:
|
||||
FEATURES: ${{ matrix.features }}
|
||||
rustfmt:
|
||||
|
||||
+20
@@ -1,3 +1,23 @@
|
||||
# Version 0.8.0
|
||||
|
||||
Changes:
|
||||
* The minimum supported rust version is now indicated in `Cargo.toml`.
|
||||
* The enums `TiffFormatError` and `TiffUnsupportedError` are now
|
||||
marked with the `#[non_exhaustive]` attribute.
|
||||
* Additionally, tag related enums `Value`, `Tags`, `Type`, `CompressionMethod`,
|
||||
`PhotometricInterpretation`, `PlanarConfiguration`, `Predictor`,
|
||||
`ResolutionUnit`, `SampleFormat` are also changed.
|
||||
|
||||
Removals:
|
||||
* Removed deprecated methods of `Decoder`: `init`, `read_jpeg`,
|
||||
`read_strip_to_buffer`, `read_strip`, `read_tile`. The implicit chunk (row or
|
||||
tile) index order could not be easily tracked by the caller. New separate
|
||||
utility interfaces may be introduced at a later point, for now callers are
|
||||
obligated to choose their own.
|
||||
|
||||
Fixes:
|
||||
* Update to `jpeg_decoder = 0.3`.
|
||||
|
||||
# Version 0.7.4
|
||||
|
||||
New features:
|
||||
|
||||
+12
-4
@@ -1,16 +1,24 @@
|
||||
[package]
|
||||
name = "tiff"
|
||||
version = "0.7.4"
|
||||
authors = ["The image-rs Developers"]
|
||||
version = "0.8.0"
|
||||
edition = "2018"
|
||||
resolver = "2"
|
||||
|
||||
# note: when changed, also update test runner in `.github/workflows/rust.yml`
|
||||
rust-version = "1.61.0"
|
||||
|
||||
license = "MIT"
|
||||
description = "TIFF decoding and encoding library in pure Rust"
|
||||
authors = ["The image-rs Developers"]
|
||||
|
||||
repository = "https://github.com/image-rs/image-tiff"
|
||||
categories = ["multimedia::images", "multimedia::encoding"]
|
||||
|
||||
exclude = ["tests/images/*", "tests/fuzz_images/*"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
weezl = "0.1.0"
|
||||
jpeg = { package = "jpeg-decoder", version = "0.2.4", default-features = false }
|
||||
jpeg = { package = "jpeg-decoder", version = "0.3.0", default-features = false }
|
||||
flate2 = "1.0.20"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
+1
-7
@@ -17,6 +17,7 @@ use self::Value::{
|
||||
|
||||
#[allow(unused_qualifications)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum Value {
|
||||
Byte(u8),
|
||||
Short(u16),
|
||||
@@ -34,8 +35,6 @@ pub enum Value {
|
||||
Ascii(String),
|
||||
Ifd(u32),
|
||||
IfdBig(u64),
|
||||
#[doc(hidden)] // Do not match against this.
|
||||
__NonExhaustive,
|
||||
}
|
||||
|
||||
impl Value {
|
||||
@@ -361,7 +360,6 @@ impl Entry {
|
||||
| Type::RATIONAL
|
||||
| Type::SRATIONAL
|
||||
| Type::IFD8 => 8,
|
||||
Type::__NonExhaustive => unreachable!(),
|
||||
};
|
||||
|
||||
let value_bytes = match self.count.checked_mul(tag_size) {
|
||||
@@ -398,7 +396,6 @@ impl Entry {
|
||||
| Type::SLONG
|
||||
| Type::FLOAT
|
||||
| Type::IFD => unreachable!(),
|
||||
Type::__NonExhaustive => unreachable!(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -444,7 +441,6 @@ impl Entry {
|
||||
reader.goto_offset(self.r(bo).read_u32()?.into())?;
|
||||
IfdBig(reader.read_u64()?)
|
||||
}
|
||||
Type::__NonExhaustive => unreachable!(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -528,7 +524,6 @@ impl Entry {
|
||||
| Type::IFD8 => {
|
||||
unreachable!()
|
||||
}
|
||||
Type::__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +606,6 @@ impl Entry {
|
||||
}
|
||||
Ok(Ascii(String::from_utf8(out)?))
|
||||
}
|
||||
Type::__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -464,7 +464,6 @@ impl Image {
|
||||
TiffUnsupportedError::FloatingPointPredictor(color_type),
|
||||
));
|
||||
}
|
||||
Predictor::__NonExhaustive => unreachable!(),
|
||||
},
|
||||
(type_, _) => {
|
||||
return Err(TiffError::UnsupportedError(
|
||||
|
||||
@@ -301,7 +301,6 @@ where
|
||||
reader: SmartReader<R>,
|
||||
bigtiff: bool,
|
||||
limits: Limits,
|
||||
current_chunk: u32,
|
||||
next_ifd: Option<u64>,
|
||||
ifd_offsets: Vec<u64>,
|
||||
seen_ifds: HashSet<u64>,
|
||||
@@ -430,7 +429,6 @@ fn fix_endianness_and_predict(
|
||||
_ => unreachable!("Caller should have validated arguments. Please file a bug."),
|
||||
}
|
||||
}
|
||||
Predictor::__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +584,6 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
chunk_offsets: Vec::new(),
|
||||
chunk_bytes: Vec::new(),
|
||||
},
|
||||
current_chunk: 0,
|
||||
};
|
||||
decoder.next_image()?;
|
||||
Ok(decoder)
|
||||
@@ -638,7 +635,6 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
if let Some(ifd_offset) = self.ifd_offsets.get(ifd_index) {
|
||||
let (ifd, _next_ifd) = Self::read_ifd(&mut self.reader, self.bigtiff, *ifd_offset)?;
|
||||
|
||||
self.current_chunk = 0;
|
||||
self.image = Image::from_reader(&mut self.reader, ifd, &self.limits, self.bigtiff)?;
|
||||
|
||||
Ok(())
|
||||
@@ -649,13 +645,6 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset the decoder.
|
||||
#[deprecated = "Never should have been public. Only use Decoder::new()"]
|
||||
pub fn init(self) -> TiffResult<Decoder<R>> {
|
||||
let Self { reader, .. } = self;
|
||||
Self::new(reader.into_inner())
|
||||
}
|
||||
|
||||
fn next_ifd(&mut self) -> TiffResult<(Directory, Option<u64>)> {
|
||||
if self.next_ifd.is_none() {
|
||||
return Err(TiffError::FormatError(
|
||||
@@ -686,7 +675,6 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
pub fn next_image(&mut self) -> TiffResult<()> {
|
||||
let (ifd, _next_ifd) = self.next_ifd()?;
|
||||
|
||||
self.current_chunk = 0;
|
||||
self.image = Image::from_reader(&mut self.reader, ifd, &self.limits, self.bigtiff)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -1037,33 +1025,6 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
Ok(u32::try_from(self.image().chunk_offsets.len())?)
|
||||
}
|
||||
|
||||
#[deprecated = "Use read_image instead"]
|
||||
pub fn read_jpeg(&mut self) -> TiffResult<DecodingResult> {
|
||||
self.read_image()
|
||||
}
|
||||
|
||||
#[deprecated = "Use read_chunk_to_buffer instead"]
|
||||
pub fn read_strip_to_buffer(&mut self, mut buffer: DecodingBuffer) -> TiffResult<()> {
|
||||
self.check_chunk_type(ChunkType::Strip)?;
|
||||
|
||||
let offset = self.image.chunk_file_range(self.current_chunk)?.0;
|
||||
self.goto_offset_u64(offset)?;
|
||||
|
||||
let byte_order = self.reader.byte_order;
|
||||
let output_width = usize::try_from(self.image().width)?;
|
||||
self.image.expand_chunk(
|
||||
&mut self.reader,
|
||||
buffer.copy(),
|
||||
output_width,
|
||||
byte_order,
|
||||
self.current_chunk,
|
||||
)?;
|
||||
|
||||
self.current_chunk += 1;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn read_chunk_to_buffer(
|
||||
&mut self,
|
||||
mut buffer: DecodingBuffer,
|
||||
@@ -1139,30 +1100,6 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a single strip from the image and return it as a Vector. This method does not return
|
||||
/// information on the size of the strip read and so the caller must take care of the final
|
||||
/// strip in the image as the data read may be less than the expected strip size. This interface
|
||||
/// may change at a future date to reflect this.
|
||||
#[deprecated = "Use read_chunk instead"]
|
||||
pub fn read_strip(&mut self) -> TiffResult<DecodingResult> {
|
||||
let result = self.read_chunk(self.current_chunk)?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Read a single tile from the image and return it as a Vector. This method does not return
|
||||
/// information on the size of the tile read and so the caller must take care of tiles on the
|
||||
/// rightmost column and the bottommost row in the image as the data read may be less than the
|
||||
/// expected tile size. This interface may change at a future date to reflect this.
|
||||
#[deprecated = "Use read_chunk instead"]
|
||||
pub fn read_tile(&mut self) -> TiffResult<DecodingResult> {
|
||||
let result = self.read_chunk(self.current_chunk)?;
|
||||
|
||||
self.current_chunk += 1;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Read the specified chunk (at index `chunk_index`) and return the binary data as a Vector.
|
||||
pub fn read_chunk(&mut self, chunk_index: u32) -> TiffResult<DecodingResult> {
|
||||
let data_dims = self.image().chunk_data_dimensions(chunk_index)?;
|
||||
|
||||
+2
-8
@@ -43,6 +43,7 @@ pub enum TiffError {
|
||||
/// The list of variants may grow to incorporate errors of future features. Matching against this
|
||||
/// exhaustively is not covered by interface stability guarantees.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum TiffFormatError {
|
||||
TiffSignatureNotFound,
|
||||
TiffSignatureInvalid,
|
||||
@@ -68,9 +69,6 @@ pub enum TiffFormatError {
|
||||
RequiredTagEmpty(Tag),
|
||||
StripTileTagConflict,
|
||||
CycleInOffsets,
|
||||
#[doc(hidden)]
|
||||
/// Do not match against this variant. It may get removed.
|
||||
__NonExhaustive,
|
||||
}
|
||||
|
||||
impl fmt::Display for TiffFormatError {
|
||||
@@ -121,7 +119,6 @@ impl fmt::Display for TiffFormatError {
|
||||
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {:?} was empty.", val),
|
||||
StripTileTagConflict => write!(fmt, "File should contain either (StripByteCounts and StripOffsets) or (TileByteCounts and TileOffsets), other combination was found."),
|
||||
CycleInOffsets => write!(fmt, "File contained a cycle in the list of IFDs"),
|
||||
__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,6 +132,7 @@ impl fmt::Display for TiffFormatError {
|
||||
/// The list of variants may grow. Matching against this exhaustively is not covered by interface
|
||||
/// stability guarantees.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum TiffUnsupportedError {
|
||||
FloatingPointPredictor(ColorType),
|
||||
HorizontalPredictor(ColorType),
|
||||
@@ -148,9 +146,6 @@ pub enum TiffUnsupportedError {
|
||||
UnsupportedBitsPerChannel(u8),
|
||||
UnsupportedPlanarConfig(Option<PlanarConfiguration>),
|
||||
UnsupportedDataType,
|
||||
#[doc(hidden)]
|
||||
/// Do not match against this variant. It may get removed.
|
||||
__NonExhaustive,
|
||||
}
|
||||
|
||||
impl fmt::Display for TiffUnsupportedError {
|
||||
@@ -196,7 +191,6 @@ impl fmt::Display for TiffUnsupportedError {
|
||||
write!(fmt, "Unsupported planar configuration “{:?}”.", config)
|
||||
}
|
||||
UnsupportedDataType => write!(fmt, "Unsupported data type."),
|
||||
__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -9,11 +9,9 @@ macro_rules! tags {
|
||||
} => {
|
||||
$( #[$enum_attr] )*
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum $name {
|
||||
$($(#[$ident_attr])* $tag,)*
|
||||
// FIXME: switch to non_exhaustive once stabilized and compiler requirement new enough
|
||||
#[doc(hidden)]
|
||||
__NonExhaustive,
|
||||
$(
|
||||
#[doc = $unknown_doc]
|
||||
Unknown($ty),
|
||||
@@ -34,7 +32,6 @@ macro_rules! tags {
|
||||
match *self {
|
||||
$( $name::$tag => $val, )*
|
||||
$( $name::Unknown(n) => { $unknown_doc; n }, )*
|
||||
$name::__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user