Skip to content
Draft
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
7 changes: 4 additions & 3 deletions src/doc/builtinplugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1543,16 +1543,17 @@ The official OpenEXR site is http://www.openexr.com/.
* - ``compression``
- string
- one of: ``"none"``, ``"rle"``, ``"zip"``, ``"zips"``, ``"piz"``,
``"pxr24"``, ``"b44"``, ``"b44a"``, ``"dwaa"``, ``"dwab"`` or ``"htj2k"``.
``"pxr24"``, ``"b44"``, ``"b44a"``, ``"dwaa"``, ``"dwab"``, ``"htj2k"`` or ``"zstd"``.
(``"htj2k"`` is only supported with OpenEXR 3.4 or later.)
(``"zstd"`` is only supported with OpenEXR 3.5 or later.)
If the writer receives a request for a compression type it does not
recognize or is not supported by the version of OpenEXR on the
system, it will use ``"zip"`` by default. For ``"dwaa"`` and
``"dwab"``, the dwaCompressionLevel may be optionally appended to the
compression name after a colon, like this: ``"dwaa:200"``. (The
default DWA compression value is 45.) For ``"zip"`` and ``"zips"``
default DWA compression value is 45.) For ``"zip"``, ``"zips"`` and ``"zstd"``
compression, a level from 1 to 9 may be appended (the default is
``"zip:4"``), but note that this is only honored when building
``"zip:4"`` and ``"zstd:5"``), but note that this is only honored when building
against OpenEXR 3.1.3 or later.
* - ``textureformat``
- string
Expand Down
3 changes: 3 additions & 0 deletions src/openexr.imageio/exrinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
case Imf::DWAB_COMPRESSION: comp = "dwab"; break;
#ifdef IMF_HTJ2K_COMPRESSION
case Imf::HTJ2K_COMPRESSION: comp = "htj2k"; break;
#endif
#ifdef IMF_ZSTD_COMPRESSION
case Imf::ZSTD_COMPRESSION: comp = "zstd"; break;
#endif
default: break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/openexr.imageio/exrinput_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ OpenEXRCoreInput::PartInfo::parse_header(OpenEXRCoreInput* in,
case EXR_COMPRESSION_DWAB: comp = "dwab"; break;
#ifdef IMF_HTJ2K_COMPRESSION
case EXR_COMPRESSION_HTJ2K: comp = "htj2k"; break;
#endif
#ifdef IMF_ZSTD_COMPRESSION
case EXR_COMPRESSION_ZSTD: comp = "zstd"; break;
#endif
default: break;
}
Expand Down
12 changes: 12 additions & 0 deletions src/openexr.imageio/exroutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,14 @@ OpenEXROutput::spec_to_header(ImageSpec& spec, int subimage,
if (Strutil::istarts_with(comp, "zip")) {
header.zipCompressionLevel() = (qual >= 1 && qual <= 9) ? qual : 4;
}
#endif
#if OPENEXR_CODED_VERSION >= 30500
// OpenEXR 3.5.0 and later allow us to pick the level. We've found
// that 5 is a great tradeoff between size and speed, so that is our
// default.
if (Strutil::istarts_with(comp, "zstd")) {
header.zstdCompressionLevel() = (qual >= 1 && qual <= 9) ? qual : 5;
}
#endif
if (Strutil::istarts_with(comp, "dwa") && qual > 0) {
#if OPENEXR_CODED_VERSION >= 30103
Expand Down Expand Up @@ -964,6 +972,10 @@ OpenEXROutput::put_parameter(const std::string& name, TypeDesc type,
#ifdef IMF_HTJ2K_COMPRESSION
else if (Strutil::iequals(str, "htj2k"))
header.compression() = Imf::HTJ2K_COMPRESSION;
#endif
#ifdef IMF_ZSTD_COMPRESSION
else if (Strutil::iequals(str, "zstd"))
header.compression() = Imf::ZSTD_COMPRESSION;
#endif
}
return true;
Expand Down
Loading