Skip to content

Conversation

@cdinea
Copy link
Contributor

@cdinea cdinea commented Nov 26, 2025

Update cuslide2 plugin for nvImageCodec v0.7.0

Description

This PR updates the cucim.kit.cuslide2 plugin to support nvImageCodec v0.7.0 from internal release, which includes new features for direct TIFF tag retrieval and API changes.

Key Changes

1. CMake Configuration (cmake/deps/nvimgcodec.cmake)

  • Updated default version from 0.6.0 to 0.7.0
  • Added NVIMGCODEC_DIR and NVIMGCODEC_ROOT variables for local installations
  • Added automatic CUDA version detection (CUDA 12 vs CUDA 13)
  • Improved library discovery for conda, pip, and system installations

2. API Compatibility Fix (nvimgcodec_decoder.cpp)

  • Breaking change in v0.7.0: Removed buffer_size assignment from nvimgcodecImageInfo_t
    • The buffer_size member was removed in v0.7.0; buffer size is now inferred from plane_info

3. TIFF Tag Support (nvimgcodec_tiff_parser.cpp)

  • New in v0.7.0: Added direct TIFF tag retrieval using NVIMGCODEC_METADATA_KIND_TIFF_TAG
  • Implemented tag querying by ID for:
    • SUBFILETYPE (254) - for associated image classification
    • COMPRESSION (259) - compression method detection
    • IMAGEDESCRIPTION (270) - vendor metadata
    • SUBIFD (330) - sub-IFD references
    • JPEGTABLES (347) - JPEG quantization/huffman tables
  • Updated enum values to match v0.7.0 API:
    NVIMGCODEC_METADATA_KIND_TIFF_TAG = 1
    NVIMGCODEC_METADATA_KIND_MED_APERIO = 5
    NVIMGCODEC_METADATA_KIND_MED_PHILIPS = 6
    NVIMGCODEC_METADATA_KIND_MED_LEICA = 7
    NVIMGCODEC_METADATA_KIND_MED_VENTANA = 8
    NVIMGCODEC_METADATA_KIND_MED_TRESTLE = 9
  • Added support for multiple TIFF value types (ASCII, SHORT, LONG, BYTE, LONG8, RATIONAL)

4. Dependencies (dependencies.yaml)

  • Updated libnvimgcodec and nvimgcodec versions to 0.7.0

Related

  • nvImageCodec v0.7.0 release notes: Adds generic TIFF tag reading, removes buffer_size from nvimgcodecImageInfo_t
  • Requires nvTIFF v0.6.0 for full functionality

cdinea and others added 30 commits November 19, 2025 16:01
- Fix libjpeg-turbo cmake configuration for both cuslide and cuslide2
- Update nvimgcodec cmake dependency configuration
- Update examples CMakeLists
- Update build scripts and documentation
Signed-off-by: cdinea <cdinea@nvidia.com>
Signed-off-by: cdinea <cdinea@nvidia.com>
Signed-off-by: cdinea <cdinea@nvidia.com>
Signed-off-by: cdinea <cdinea@nvidia.com>
Co-authored-by: jakirkham <jakirkham@gmail.com>
Co-authored-by: jakirkham <jakirkham@gmail.com>
Co-authored-by: jakirkham <jakirkham@gmail.com>
Co-authored-by: jakirkham <jakirkham@gmail.com>
}

// Store ImageDescription if available from vendor metadata
if (!ifd_info.image_description.empty())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you remove code that sets it based on vendor metadata in a recent commit?

Copy link
Contributor Author

@cdinea cdinea Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the feedback @mkepa-nv -image_description is now only set from tiff_tags, so it would always be empty in that fallback path. Removed in this commit

try
{
// Get compression value from typed variant
uint16_t compression_value = tiff_tag_value_to_uint16(compression_it->second);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compression tag should be SHORT right? So maybe it is better to just check if that is the case and throw exception in the unlikely case that it is not? And we can get rid of this whole tiff_tag_value_to_uint16 function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think youu are right @mkepa-nv .the COMPRESSION tag is always SHORT per TIFF spec. I've removed the conversion helper and switched to std::get<uint16_t>() directly in this commit


// Convert value based on type and store as typed variant
TiffTagValue tag_value;
bool value_stored = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value_stored is not needed. The variant will be initialized into first type from its list - so std::monotstate. We can just check at the end if type is still monostate with either:

  • tag_value.index() == 0
  • std::holds_alternative<std::monotstate>(tag_value))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the feedback @mkepa-nv - I addressed this feedback in this commit

uint16_t compression_value = tiff_tag_value_to_uint16(compression_it->second);
// COMPRESSION tag is always SHORT (uint16_t) per TIFF spec
// If it's not, that indicates a bug in nvImageCodec or our parsing
uint16_t compression_value = std::get<uint16_t>(compression_it->second);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to directly check if type is correct via https://en.cppreference.com/w/cpp/utility/variant/holds_alternative.html instead of relying on exceptions? But I don't have strong opinions on that, we can leave catch too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the suggestion @mkepa-nv - this is a good idea and i addressed it in this committ

@cdinea
Copy link
Contributor Author

cdinea commented Dec 1, 2025

/ok to test 2716b26

@cdinea
Copy link
Contributor Author

cdinea commented Dec 1, 2025

/ok to test c944ffd

@cdinea
Copy link
Contributor Author

cdinea commented Dec 1, 2025

/ok to test 7b402de

@cdinea
Copy link
Contributor Author

cdinea commented Dec 1, 2025

@KyleFromNVIDIA @jakirkham - The CI is experiencing persistent conda-forge network timeouts.
Could this be a CI runner network/configuration issue?

@cdinea cdinea changed the base branch from release/25.12 to main December 2, 2025 19:54
@cdinea cdinea removed this from the v25.12.00 milestone Dec 4, 2025
Comment on lines 71 to +76
- libnvjpeg
- libnvimgcodec0 {{ nvimgcodec_version }} # nvImageCodec runtime library
run_constrained:
- {{ pin_compatible('openslide') }}
- libnvimgcodec-dev {{ nvimgcodec_version }} # Optional: for development/debugging

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- libnvjpeg
- libnvimgcodec0 {{ nvimgcodec_version }} # nvImageCodec runtime library
run_constrained:
- {{ pin_compatible('openslide') }}
- libnvimgcodec-dev {{ nvimgcodec_version }} # Optional: for development/debugging
- libnvjpeg
run_constrained:
- {{ pin_compatible('openslide') }}

These constraints aren't necessary. libnvimgcodec-dev has appropriate run_exports, and your constraints are less strict than the run_exports.

@cdinea cdinea changed the base branch from main to release/25.12 December 4, 2025 23:06
@cdinea cdinea changed the base branch from release/25.12 to main December 4, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change improvement Improves an existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants