From cbae42ea94163707d799a1569f2aca1842d00480 Mon Sep 17 00:00:00 2001 From: Onno Kammeraad Date: Wed, 6 Nov 2019 14:04:18 +0100 Subject: [PATCH] fixed support for multipage images, the IDF offset is added during the new and also at the end of the internal_finish. This should only be done once --- src/encoder/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index 96ba414..ab626cf 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -1,6 +1,7 @@ use byteorder::NativeEndian; use std::collections::BTreeMap; use std::io::{Seek, Write}; +use std::mem; use decoder::ifd::{self, Tag}; use error::{TiffError, TiffFormatError, TiffResult}; @@ -351,6 +352,8 @@ impl TiffEncoder { }; NativeEndian::write_header(&mut encoder.writer)?; + // blank the IFD offset location + encoder.writer.write_u32(0)?; Ok(encoder) } @@ -417,9 +420,9 @@ pub struct DirectoryEncoder<'a, W: 'a + Write + Seek> { impl<'a, W: 'a + Write + Seek> DirectoryEncoder<'a, W> { fn new(writer: &'a mut TiffWriter) -> TiffResult> { + // the previous word is the IFD offset position + let ifd_pointer_pos = writer.offset() - mem::size_of::() as u64; writer.pad_word_boundary()?; - let ifd_pointer_pos = writer.offset(); - writer.write_u32(0)?; Ok(DirectoryEncoder { writer, dropped: false,