NVIDIA nvImageCodec#

The nvImageCodec is a library of accelerated codecs with unified interface. It is designed as a framework for extension modules which delivers codec plugins. The following image illustrates the simplified architecture of nvImageCodec.

_images/architecture_overview.png

Key features#

Accessible on multiple platforms#

Architecture

Distribution Info

Name

Version

x86_64

Debian

12

OpenSUSE Leap

15

RHEL/CentOS

8, 9

Rocky

8, 9

Fedora

41

SUSE SLES

15

Ubuntu

20.04, 22.04, 24.04

WSL2 Ubuntu

20.04

Windows

10, 11

arm64-sbsa

RHEL

8, 9

SUSE SLES

15

Ubuntu

20.04, 22.04, 24.04

aarch64-jetson

Ubuntu

22.04

Cuda Python PyPI - Wheel

Easy installation#

# For windows, linux and sbsa
pip install nvidia-nvimgcodec-cu12[all]

# For tegra
pip install  nvidia-nvimgcodec-tegra-cu12[all]

# You can specify a subset of the dependencies: nvjpeg, nvjpeg2k, nvtiff
# depending what codecs would you like to use. For example:
pip install nvidia-nvimgcodec-cu12[nvjpeg2k,nvtiff]

For more options, please see Installation documentation.

Unified C and Python API for decoding and encoding images#

from nvidia import nvimgcodec
nv_img = nvimgcodec.Decoder().read("cat-1046544_640.jp2")
nvimgcodec.Encoder().write("cat-jp2-o.jpg", nv_img)

Batch processing, with variable shape and heterogeneous formats images#

import os.path as p
from nvidia import nvimgcodec
image_paths = ["cat-1046544_640.jp2", "tabby_tiger_cat.jpg", "Weimaraner.bmp"]
image_list = nvimgcodec.Decoder().read(image_paths)
out_file_names = [p.splitext(p.basename(i))[0] + "_out.jpg" for i in image_paths]

nvimgcodec.Encoder().write(out_file_names, image_list, ".jpg")

NVIDIA accelerated and 3 rd party codecs with prioritization and automatic fallback#

_images/codecs.png

Zero-copy interfaces to CV-CUDA, PyTorch, Tensorflow, CuPy and more#

from nvidia import nvimgcodec
import cupy as cp; import cupyx.scipy.ndimage
from matplotlib import pyplot as plt

nv_img = nvimgcodec.Decoder().read("images/tabby_tiger_cat.jpg")
cp_img = cp.asarray(nv_img) # zero-copy
print('nvImageCodec device pointer: ', nv_img.__cuda_array_interface__['data'][0], end='')
print('CuPy device pointer:', cp_img.__cuda_array_interface__['data'][0])

cp_img_rotated = cupyx.scipy.ndimage.rotate(cp_img, 90)
nvimgcodec.Encoder().write("rotated_cat.jp2", cp_img_rotated)

nv_rotated_img = nvimgcodec.as_image(cp_img_rotated)
plt.imshow(nv_rotated_img.cpu())