NVIMGCODEC_MAX_IMAGE_SIZE is parsed as a bool: any value becomes a 1 byte limit and every decode returns None
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, computer-vision
Research direction
Start in python/decoder.cpp near the reported line 240 and inspect how NVIMGCODEC_MAX_IMAGE_SIZE is parsed. Then read test/python/test_cpu_only.py for existing decoder test patterns and reproduce with the issue's 16×16 PPM example in a fresh interpreter. Done means a configured byte limit is honored and the regression test passes.
Written by the indexing model from the issue text.
Description
Version
0.10.0 (wheel nvidia-nvimgcodec-cu12==0.10.0.9; also main at 77a7d15)
Describe the bug.
Setting NVIMGCODEC_MAX_IMAGE_SIZE to any non-zero value makes the Python Decoder return None for every image. The warning shows that the limit was read as 1:
768 > NVIMGCODEC_MAX_IMAGE_SIZE(1)
Expected: the value is used as a byte limit, so a 768 byte image decodes with NVIMGCODEC_MAX_IMAGE_SIZE=100000000. The warning text itself describes the variable as the maximum "Total image volume (height x width x channels x bytes_per_sample)".
The cause is in python/decoder.cpp (line 240 on main):
static const size_t max_image_sz = max_image_size_str && atol(max_image_size_str);
&& gives a bool, so max_image_sz is 0 or 1. The same expression is in the v0.3.0, v0.5.0 and v0.7.0 to v0.10.0 sources.
Minimum reproducible example
cat > repro.py <<'PY'
import os
from nvidia import nvimgcodec
print("nvimgcodec", nvimgcodec.__version__)
print("NVIMGCODEC_MAX_IMAGE_SIZE =", os.environ.get("NVIMGCODEC_MAX_IMAGE_SIZE"))
# A 16x16 binary PPM, 768 bytes of pixel data.
ppm = b"P6\n16 16\n255\n" + bytes(16 * 16 * 3)
decoder = nvimgcodec.Decoder(
device_id=nvimgcodec.NVIMGCODEC_DEVICE_CPU_ONLY,
backends=[nvimgcodec.Backend(nvimgcodec.BackendKind.CPU_ONLY)],
)
image = decoder.decode(ppm)
print("decoded:", None if image is None else image.shape)
PY
NVIMGCODEC_MAX_IMAGE_SIZE=100000000 python repro.py
Environment details
tools/print_env.sh was not run. Environment used for the repro:
x86_64 Linux, Ubuntu 24.04, Python 3.12
nvidia-nvimgcodec-cu12 0.10.0.9, CPU-only backend, no GPU visible (CUDA_VISIBLE_DEVICES empty)
Also reproduced with a from-source build of main 77a7d15 (CUDA toolkit 12.9, GCC 14.4)
Relevant log output
[WARNING] [pynvimgcodec] Total image volume (height x width x channels x bytes_per_sample) exceeds the maximum configured value: 768 > NVIMGCODEC_MAX_IMAGE_SIZE(1). Use NVIMGCODEC_MAX_IMAGE_SIZE env variable to control this maximum value.
nvimgcodec 0.10.0
NVIMGCODEC_MAX_IMAGE_SIZE = 100000000
decoded: None
Without the variable the same script prints decoded: (16, 16, 3).
Other/Misc.
A local fix is available if useful: parse the value with atoll and treat a missing, non-numeric or non-positive value as "no limit", plus a test in test/python/test_cpu_only.py that sets the variable in a fresh interpreter. The new test fails on main and passes with the change. One behaviour change: a negative value would mean "no limit" instead of "limit 1".
Check for duplicates
- I have searched the open bugs/issues and have found no duplicates for this bug report
This was found with an AI coding assistant (Claude Code, claude-fable-5-2), which also wrote and ran the repro above and drafted this report.
- Dominant language
- Jupyter Notebook
- Stars
- 164
- Forks
- 26
- Avg merge
- 27m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/nvImageCodec
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
NVIDIA/nvImageCodec#66 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
NVIDIA/nvImageCodec#64 ·
-
nvjpeg2k error 3 (Bad jpeg) on valid JPEG 2000 aerial photos that OpenJPEG and ffmpeg decode identicallyPossibly taken @mkepa-nv claimed this 7 days ago. Openbug
NVIDIA/nvImageCodec#63 · 2 comments · 1 assignee ·
-
Experimental small-batch CUDA baseline JPEG decoding corePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 5/5 Over a week Newbie friendliness 8/100
NVIDIA/nvImageCodec#60 ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
NVIDIA/nvImageCodec#59 ·
All issues in NVIDIA/nvImageCodec
Similar issues
-
changelog investigate
Difficulty 1/5 Under an hour Newbie friendliness 85/100
ramnes/notion-sdk-py#454 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
anthropics/claude-agent-sdk-python#1509 ·
Maintainers usually reply within 2 days
-
from-review-extraction priority: medium python severity:suggested
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
LearningCircuit/local-deep-research#8665 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
external feature request openai
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
langchain-ai/langchain#41853 ·
Maintainers usually reply within 1 day