Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
* **CMake >= 3.23.0** (tested through 4.4)
* Imath >= 3.1 (tested through 3.2 and main)
* OpenEXR >= 3.1 (tested through 3.4 and main)
* libTIFF >= 4.0 (tested through 4.7 and master)
* **libTIFF >= 4.1** (tested through 4.7 and master)
* OpenColorIO >= 2.3 (tested through 2.5 and main)
* libjpeg >= 8 (tested through jpeg9e), or libjpeg-turbo >= 2.1 (tested
through 3.2)
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if (NOT TARGET Deflate::Deflate)
endif ()

checked_find_package (TIFF REQUIRED
VERSION_MIN 4.0
VERSION_MIN 4.1
RECOMMEND_MIN 4.5
RECOMMEND_MIN_REASON "4.2+ for GPS, 4.5+ various security fixes")
alias_library_if_not_exists (TIFF::TIFF TIFF::tiff)
Expand Down
1 change: 1 addition & 0 deletions src/tiff.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_oiio_plugin (tiffinput.cpp tiffoutput.cpp
ZLIB::ZLIB
$<TARGET_NAME_IF_EXISTS:libjpeg-turbo::jpeg>
$<TARGET_NAME_IF_EXISTS:JPEG::JPEG>
$<TARGET_NAME_IF_EXISTS:Deflate::Deflate>
)

# TODO: It's not clear that we need to explicitly list the ZLIB and JPEG
Expand Down
11 changes: 3 additions & 8 deletions src/tiff.imageio/tiffinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@
# define OIIO_TIFFLIB_VERSION 40200
#elif TIFFLIB_VERSION >= 20191103
# define OIIO_TIFFLIB_VERSION 40100
#elif TIFFLIB_VERSION >= 20120922
# define OIIO_TIFFLIB_VERSION 40003
#elif TIFFLIB_VERSION >= 20111221
# define OIIO_TIFFLIB_VERSION 40000
#else
# error "libtiff 4.0.0 or later is required"
# error "libtiff 4.1.0 or later is required"
#endif
// clang-format on

Expand Down Expand Up @@ -819,12 +815,11 @@ static std::pair<int, const char*> tiff_input_compressions[] = {
{ COMPRESSION_SGILOG, "sgilog" }, // SGI log luminance RLE
{ COMPRESSION_SGILOG24, "sgilog24" }, // SGI log 24bit
{ COMPRESSION_JP2000, "jp2000" }, // Leadtools JPEG2000
#if defined(TIFF_VERSION_BIG) && OIIO_TIFFLIB_VERSION >= 40003
// Others supported in more recent TIFF library versions.
{ COMPRESSION_T85, "T85" }, // TIFF/FX T.85 JBIG
{ COMPRESSION_T43, "T43" }, // TIFF/FX T.43 color layered JBIG
{ COMPRESSION_LZMA, "lzma" }, // LZMA2
#endif
{ COMPRESSION_ZSTD, "zstd" }, // zstd
{ COMPRESSION_WEBP, "webp" }, // webp
};

// clang-format on
Expand Down
58 changes: 26 additions & 32 deletions src/tiff.imageio/tiffoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iostream>
#include <memory>

#include <tiffconf.h>
#include <tiffio.h>
#include <zlib.h>

Expand Down Expand Up @@ -41,12 +42,8 @@
# define OIIO_TIFFLIB_VERSION 40200
#elif TIFFLIB_VERSION >= 20191103
# define OIIO_TIFFLIB_VERSION 40100
#elif TIFFLIB_VERSION >= 20120922
# define OIIO_TIFFLIB_VERSION 40003
#elif TIFFLIB_VERSION >= 20111221
# define OIIO_TIFFLIB_VERSION 40000
#else
# error "libtiff 4.0.0 or later is required"
# error "libtiff 4.1.0 or later is required"
#endif
// clang-format on

Expand Down Expand Up @@ -317,24 +314,23 @@ static std::pair<int, const char*> tiff_output_compressions[] = {
// { COMPRESSION_NEXT, "next" }, // NeXT 2-bit RLE
// { COMPRESSION_CCITTRLEW, "ccittrle2" }, // #1 w/ word alignment
{ COMPRESSION_PACKBITS, "packbits" }, // Macintosh RLE
// { COMPRESSION_THUNDERSCAN, "thunderscan" }, // ThundeScan RLE
// { COMPRESSION_IT8CTPAD, "IT8CTPAD" }, // IT8 CT w/ patting
// { COMPRESSION_IT8LW, "IT8LW" }, // IT8 linework RLE
// { COMPRESSION_IT8MP, "IT8MP" }, // IT8 monochrome picture
// { COMPRESSION_IT8BL, "IT8BL" }, // IT8 binary line art
// { COMPRESSION_PIXARFILM, "pixarfilm" }, // Pixar 10 bit LZW
// { COMPRESSION_PIXARLOG, "pixarlog" }, // Pixar 11 bit ZIP
// { COMPRESSION_DCS, "dcs" }, // Kodak DCS encoding
// { COMPRESSION_JBIG, "isojbig" }, // ISO JBIG
// { COMPRESSION_SGILOG, "sgilog" }, // SGI log luminance RLE
// { COMPRESSION_SGILOG24, "sgilog24" }, // SGI log 24bit
// { COMPRESSION_JP2000, "jp2000" }, // Leadtools JPEG2000
#if defined(TIFF_VERSION_BIG) && OIIO_TIFFLIB_VERSION >= 40003
// Others supported in more recent TIFF library versions.
// { COMPRESSION_T85, "T85" }, // TIFF/FX T.85 JBIG
// { COMPRESSION_T43, "T43" }, // TIFF/FX T.43 color layered JBIG
// { COMPRESSION_LZMA, "lzma" }, // LZMA2
#endif
// { COMPRESSION_THUNDERSCAN, "thunderscan" }, // ThundeScan RLE
// { COMPRESSION_IT8CTPAD, "IT8CTPAD" }, // IT8 CT w/ patting
// { COMPRESSION_IT8LW, "IT8LW" }, // IT8 linework RLE
// { COMPRESSION_IT8MP, "IT8MP" }, // IT8 monochrome picture
// { COMPRESSION_IT8BL, "IT8BL" }, // IT8 binary line art
// { COMPRESSION_PIXARFILM, "pixarfilm" }, // Pixar 10 bit LZW
// { COMPRESSION_PIXARLOG, "pixarlog" }, // Pixar 11 bit ZIP
// { COMPRESSION_DCS, "dcs" }, // Kodak DCS encoding
// { COMPRESSION_JBIG, "isojbig" }, // ISO JBIG
// { COMPRESSION_SGILOG, "sgilog" }, // SGI log luminance RLE
// { COMPRESSION_SGILOG24, "sgilog24" }, // SGI log 24bit
// { COMPRESSION_JP2000, "jp2000" }, // Leadtools JPEG2000
// { COMPRESSION_T85, "T85" }, // TIFF/FX T.85 JBIG
// { COMPRESSION_T43, "T43" }, // TIFF/FX T.43 color layered JBIG
// { COMPRESSION_LZMA, "lzma" }, // LZMA2
// { COMPRESSION_ZSTD, "zstd" }, // zstd
// { COMPRESSION_WEBP, "webp" }, // webp
};

static int
Expand Down Expand Up @@ -1088,7 +1084,6 @@ TIFFOutput::put_parameter(const ParamValue& param)
bool
TIFFOutput::write_exif_data()
{
#if defined(TIFF_VERSION_BIG) && OIIO_TIFFLIB_VERSION >= 40003
// Older versions of libtiff do not support writing Exif directories

if (m_spec.get_int_attribute("tiff:write_exif", 1) == 0) {
Expand All @@ -1112,25 +1107,25 @@ TIFFOutput::write_exif_data()
continue; // libtiff doesn't understand these
any_exif = true;
}
# if OIIO_TIFFLIB_VERSION >= 40200
#if OIIO_TIFFLIB_VERSION >= 40200
if (!any_gps && gps_tag_lookup(p.name(), tag, tifftype, count)
&& tifftype != TIFF_NOTYPE) {
any_gps = true;
}
# endif
#endif
if (any_exif && any_gps)
break; // If we've found both kinds, we're done
}
if (!any_exif && !any_gps)
return true;

# if ENABLE_JPEG_COMPRESSION
#if ENABLE_JPEG_COMPRESSION
if (m_compression == COMPRESSION_JPEG) {
// For reasons we don't understand, JPEG-compressed TIFF seems
// to not output properly without a directory checkpoint here.
TIFFCheckpointDirectory(m_tif);
}
# endif
#endif

// First, finish writing the current directory
if (!TIFFWriteDirectory(m_tif)) {
Expand All @@ -1147,7 +1142,7 @@ TIFFOutput::write_exif_data()
}
exif_dir_offset = write_extra_tag_directory("Exif");
}
# if OIIO_TIFFLIB_VERSION >= 40200
#if OIIO_TIFFLIB_VERSION >= 40200
uint64_t gps_dir_offset = 0;
if (any_gps) {
// Create a GPS directory
Expand All @@ -1157,17 +1152,16 @@ TIFFOutput::write_exif_data()
}
gps_dir_offset = write_extra_tag_directory("GPS");
}
# endif
#endif

// Go back to the first directory, and add the EXIFIFD pointer.
// std::cout << "diffdir = " << tiffdir << "\n";
TIFFSetDirectory(m_tif, 0);
if (exif_dir_offset)
TIFFSetField(m_tif, TIFFTAG_EXIFIFD, exif_dir_offset);
# if OIIO_TIFFLIB_VERSION >= 40200
#if OIIO_TIFFLIB_VERSION >= 40200
if (gps_dir_offset)
TIFFSetField(m_tif, TIFFTAG_GPSIFD, gps_dir_offset);
# endif
#endif

return true; // all is ok
Expand Down
Loading