NVIDIA / nvImageCodec

A nvImageCodec library of GPU- and CPU- accelerated codecs featuring a unified interface
https://docs.nvidia.com/cuda/nvimagecodec/index.html
Apache License 2.0
65 stars 5 forks source link

1CH Image Read as 3CH #16

Open 5had3z opened 2 weeks ago

5had3z commented 2 weeks ago

Version

0.3.0.5

Describe the bug.

When reading an 1ch 8bit image, nvimgcodec returns a 3ch 8bit image. OpenCV has the same behaviour when not specifying a format. When specifying flagging IMREAD_UNCHANGED it reads as 1ch. PIL reads correctly by default.

Minimum reproducible example

#!/usr/bin/env python3
from pathlib import Path
import numpy as np
from PIL import Image
from nvidia import nvimgcodec

test_file = Path("test_im.png")
size = (512, 512)
im_data = np.random.uniform(0, 255, size=size).astype(np.uint8)
print(f"Saving image with {im_data.shape=}")
Image.fromarray(im_data).save(test_file)

decoder = nvimgcodec.Decoder()
nv_img = decoder.decode(test_file.read_bytes())

print(f"NV image with {nv_img.shape=}")

import cv2

cv_img = cv2.imread(str(test_file))
print(f"CV default image with {cv_img.shape=}")

cv_img = cv2.imread(str(test_file), cv2.IMREAD_UNCHANGED)
print(f"CV unchanged image with {cv_img.shape=}")

pil_image = Image.open(test_file)
print(f"PIL default image with {pil_image.size=}")

Environment details

<details><summary>Click here to see environment details</summary><pre>

     **git***
     Not inside a git repository

     ***OS Information***
     DISTRIB_ID=Ubuntu
     DISTRIB_RELEASE=22.04
     DISTRIB_CODENAME=jammy
     DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
     PRETTY_NAME="Ubuntu 22.04.4 LTS"
     NAME="Ubuntu"
     VERSION_ID="22.04"
     VERSION="22.04.4 LTS (Jammy Jellyfish)"
     VERSION_CODENAME=jammy
     ID=ubuntu
     ID_LIKE=debian
     HOME_URL="https://www.ubuntu.com/"
     SUPPORT_URL="https://help.ubuntu.com/"
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
     UBUNTU_CODENAME=jammy
     Linux bryce-ws 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

     ***GPU Information***
     Mon Aug 26 22:22:57 2024
     +-----------------------------------------------------------------------------------------+
     | NVIDIA-SMI 560.28.03              Driver Version: 560.28.03      CUDA Version: 12.6     |
     |-----------------------------------------+------------------------+----------------------+
     | GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
     |                                         |                        |               MIG M. |
     |=========================================+========================+======================|
     |   0  NVIDIA GeForce RTX 3090        Off |   00000000:0B:00.0  On |                  N/A |
     | 63%   45C    P0            129W /  370W |     891MiB /  24576MiB |      0%      Default |
     |                                         |                        |                  N/A |
     +-----------------------------------------+------------------------+----------------------+

     +-----------------------------------------------------------------------------------------+
     | Processes:                                                                              |
     |  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
     |        ID   ID                                                               Usage      |
     |=========================================================================================|
     |    0   N/A  N/A      2684      G   /usr/lib/xorg/Xorg                            437MiB |
     |    0   N/A  N/A      2950      G   /usr/bin/gnome-shell                           72MiB |
     |    0   N/A  N/A      4988      G   ...seed-version=20240823-130058.581000        114MiB |
     |    0   N/A  N/A    206347      G   ...erProcess --variations-seed-version        134MiB |
     |    0   N/A  N/A    241785      G   ...yOnDemand --variations-seed-version         44MiB |
     +-----------------------------------------------------------------------------------------+

     ***CPU***
     Architecture:                         x86_64
     CPU op-mode(s):                       32-bit, 64-bit
     Address sizes:                        48 bits physical, 48 bits virtual
     Byte Order:                           Little Endian
     CPU(s):                               32
     On-line CPU(s) list:                  0-31
     Vendor ID:                            AuthenticAMD
     Model name:                           AMD Ryzen 9 5950X 16-Core Processor
     CPU family:                           25
     Model:                                33
     Thread(s) per core:                   2
     Core(s) per socket:                   16
     Socket(s):                            1
     Stepping:                             0
     Frequency boost:                      enabled
     CPU max MHz:                          5083.3979
     CPU min MHz:                          2200.0000
     BogoMIPS:                             6799.92
     Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm debug_swap
     Virtualisation:                       AMD-V
     L1d cache:                            512 KiB (16 instances)
     L1i cache:                            512 KiB (16 instances)
     L2 cache:                             8 MiB (16 instances)
     L3 cache:                             64 MiB (2 instances)
     NUMA node(s):                         1
     NUMA node0 CPU(s):                    0-31
     Vulnerability Gather data sampling:   Not affected
     Vulnerability Itlb multihit:          Not affected
     Vulnerability L1tf:                   Not affected
     Vulnerability Mds:                    Not affected
     Vulnerability Meltdown:               Not affected
     Vulnerability Mmio stale data:        Not affected
     Vulnerability Reg file data sampling: Not affected
     Vulnerability Retbleed:               Not affected
     Vulnerability Spec rstack overflow:   Mitigation; Safe RET
     Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
     Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
     Vulnerability Spectre v2:             Mitigation; Retpolines; IBPB conditional; IBRS_FW; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
     Vulnerability Srbds:                  Not affected
     Vulnerability Tsx async abort:        Not affected

     ***CMake***
     /usr/bin/cmake
     cmake version 3.30.2

     CMake suite maintained and supported by Kitware (kitware.com/cmake).

     ***g++***
     /usr/bin/g++
     g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
     Copyright (C) 2021 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

     ***nvcc***
     /usr/local/cuda/bin/nvcc
     nvcc: NVIDIA (R) Cuda compiler driver
     Copyright (c) 2005-2024 NVIDIA Corporation
     Built on Fri_Jun_14_16:34:21_PDT_2024
     Cuda compilation tools, release 12.6, V12.6.20
     Build cuda_12.6.r12.6/compiler.34431801_0

     ***Python***

     ***Environment Variables***
     PATH                            : /usr/local/cuda/bin:/usr/local/MATLAB/R2023b/bin:/home/bryce/Documents/protoc-3.19.4-linux-x86_64/bin:/home/bryce/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
     LD_LIBRARY_PATH                 : /usr/local/cuda/lib64
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    :
     PYTHON_PATH                     :

     conda not found
     ***pip packages***
     /home/bryce/.local/bin/pip
     Package                                  Version            Editable project location
     ---------------------------------------- ------------------ -----------------------------------
     absl-py                                  1.4.0
     accelerate                               0.27.2
     aiohttp                                  3.8.6
     aiohttp-cors                             0.7.0
     aiorwlock                                1.3.0
     aiosignal                                1.3.1
     alabaster                                0.7.16
     ansi2html                                1.8.0
     antlr4-python3-runtime                   4.9.3
     anyio                                    3.7.1
     appdirs                                  1.4.4
     apturl                                   0.5.2
     argcomplete                              3.5.0
     array-record                             0.5.0
     asciitree                                0.3.3
     asn1crypto                               1.4.0
     asttokens                                2.4.1
     astunparse                               1.6.3
     async-timeout                            4.0.3
     attrs                                    23.1.0
     Babel                                    2.15.0
     backoff                                  2.2.1
     bcrypt                                   4.0.1
     bitsandbytes                             0.42.0
     black                                    24.4.2
     blessed                                  1.20.0
     blinker                                  1.4
     bokeh                                    3.2.2
     Bottleneck                               1.3.8
     breathe                                  4.35.0
     Brlapi                                   0.8.3
     build                                    1.2.1
     cachetools                               5.3.1
     certifi                                  2020.6.20
     cffi                                     1.15.1
     cfgv                                     3.4.0
     chardet                                  4.0.0
     charset-normalizer                       3.2.0
     chasing_targets_gym                      0.0.5              /home/bryce/dev/chasing-targets-gym
     cityscapesScripts                        2.2.1
     click                                    8.0.3
     click-plugins                            1.1.1
     cligj                                    0.7.2
     cloudpickle                              2.2.1
     cmake                                    3.25.0
     cmake-format                             0.6.13
     cmakelang                                0.6.13
     colorama                                 0.4.4
     coloredlogs                              15.0.1
     colorful                                 0.5.5
     comm                                     0.2.2
     command-not-found                        0.3
     contourpy                                1.1.0
     cryptography                             41.0.3
     cupshelpers                              1.0
     cycler                                   0.11.0
     dacite                                   1.8.1
     dash                                     2.14.0
     dash-bootstrap-components                1.5.0
     dash-core-components                     2.0.0
     dash-cytoscape                           0.3.0
     dash-html-components                     2.0.0
     dash-table                               5.0.0
     dask                                     2023.3.1
     dataclass_array                          1.5.1
     dbus-python                              1.2.18
     debugpy                                  1.8.1
     decorator                                5.1.1
     deepdiff                                 6.6.1
     defer                                    1.0.6
     Deprecated                               1.2.14
     detectron2                               0.6
     dill                                     0.3.7
     distlib                                  0.3.7
     distro                                   1.7.0
     distro-info                              1.1+ubuntu0.2
     dm-env                                   1.6
     dm-env-rpc                               1.1.6
     dm-tree                                  0.1.8
     docker                                   7.0.0
     docker-pycreds                           0.4.0
     docutils                                 0.21.2
     einops                                   0.6.1
     einsum                                   0.3.0
     entrypoints                              0.4
     enum34                                   1.1.10
     etils                                    1.5.2
     exceptiongroup                           1.1.3
     executing                                2.0.1
     fairscale                                0.4.13
     Farama-Notifications                     0.0.4
     fastapi                                  0.104.0
     fasteners                                0.18
     ffmpegcv                                 0.3.14
     filelock                                 3.9.0
     Fiona                                    1.9.4.post1
     flake8                                   7.1.1
     flake8-bugbear                           24.4.26
     Flask                                    2.2.5
     flatbuffers                              23.5.26
     fonttools                                4.42.0
     frozenlist                               1.4.0
     fsspec                                   2023.9.2
     future                                   0.18.3
     fvcore                                   0.1.5.post20221221
     gast                                     0.4.0
     geopandas                                0.13.2
     gitdb                                    4.0.10
     GitPython                                3.1.37
     google-api-core                          2.12.0
     google-auth                              2.16.2
     google-auth-oauthlib                     0.4.6
     google-pasta                             0.2.0
     googleapis-common-protos                 1.63.2
     gpustat                                  1.1.1
     GPUtil                                   1.4.0
     greenlet                                 3.0.3
     grpcio                                   1.57.0
     gymnasium                                0.29.1
     h11                                      0.14.0
     h5py                                     3.9.0
     html5lib                                 1.1
     httplib2                                 0.20.2
     huggingface-hub                          0.21.4
     humanfriendly                            10.0
     hydra-core                               1.3.2
     identify                                 2.5.32
     idna                                     3.3
     imagecodecs                              2024.1.1
     imageio                                  2.31.5
     imagesize                                1.4.1
     immutabledict                            2.2.0
     importlib-metadata                       6.8.0
     importlib-resources                      6.1.1
     iniconfig                                2.0.0
     intel-extension-for-pytorch              2.2.0
     iopath                                   0.1.9
     iotop                                    0.6
     ipykernel                                6.29.3
     ipython                                  8.22.2
     isort                                    5.12.0
     itsdangerous                             2.1.2
     jax-jumpy                                1.0.0
     jedi                                     0.19.1
     jeepney                                  0.7.1
     Jinja2                                   3.1.2
     joblib                                   1.3.2
     jsonschema                               4.19.1
     jsonschema-specifications                2023.7.1
     jupyter_client                           8.6.1
     jupyter_core                             5.7.2
     keras                                    2.11.0
     keyring                                  23.5.0
     kiwisolver                               1.4.4
     konductor                                0.0.9.dev3         /home/bryce/dev/konductor
     kornia                                   0.7.0
     lanelet2                                 1.2.1
     language-selector                        0.1
     lark                                     1.1.8
     launchpadlib                             1.10.16
     lazr.restfulclient                       0.14.4
     lazr.uri                                 1.0.6
     lazy_loader                              0.3
     libclang                                 16.0.6
     lit                                      15.0.7
     livereload                               2.6.3
     llvmlite                                 0.43.0
     locket                                   1.0.0
     louis                                    3.20.0
     lxml                                     4.9.3
     lz4                                      4.3.2
     macaroonbakery                           1.3.1
     Markdown                                 3.4.4
     markdown-it-py                           3.0.0
     MarkupSafe                               2.1.2
     matplotlib                               3.9.1
     matplotlib-inline                        0.1.6
     mccabe                                   0.7.0
     mdurl                                    0.1.2
     mechanize                                0.4.7
     minio                                    7.1.16
     mkdocs                                   1.1.2
     mock                                     5.1.0
     more-itertools                           8.10.0
     mpmath                                   1.2.1
     mpyq                                     0.2.5
     msgpack                                  1.0.7
     multidict                                6.0.4
     MultiScaleDeformableAttention            1.0
     mypy-extensions                          1.0.0
     nest-asyncio                             1.5.8
     netifaces                                0.11.0
     networkx                                 3.0
     nh3                                      0.2.18
     ninja                                    1.11.1.1
     nodeenv                                  1.8.0
     numba                                    0.60.0
     numcodecs                                0.11.0
     numpy                                    1.26.2
     nvidia-cublas-cu12                       12.4.2.65
     nvidia-cuda-cupti-cu12                   12.4.99
     nvidia-cuda-nvrtc-cu12                   12.4.99
     nvidia-cuda-runtime-cu12                 12.4.99
     nvidia-cudnn-cu12                        9.1.0.70
     nvidia-cufft-cu12                        11.2.0.44
     nvidia-curand-cu12                       10.3.5.119
     nvidia-cusolver-cu12                     11.6.0.99
     nvidia-cusparse-cu12                     12.3.0.142
     nvidia-dali-cuda120                      1.37.1
     nvidia-ml-py                             12.555.43
     nvidia-ml-py3                            7.352.0
     nvidia-nccl-cu12                         2.20.5
     nvidia-nvimgcodec-cu12                   0.3.0.5
     nvidia-nvjitlink-cu12                    12.4.99
     nvidia-nvtx-cu12                         12.4.99
     oauthlib                                 3.2.0
     olefile                                  0.46
     omegaconf                                2.3.0
     onnx                                     1.16.2
     onnxruntime-gpu                          1.19.0
     opencensus                               0.11.3
     opencensus-context                       0.1.3
     openconnect-sso                          0.8.1
     opencv-python                            4.8.0.76
     OpenEXR                                  1.3.9
     opentelemetry-api                        1.20.0
     opentelemetry-exporter-otlp              1.20.0
     opentelemetry-exporter-otlp-proto-common 1.20.0
     opentelemetry-exporter-otlp-proto-grpc   1.20.0
     opentelemetry-exporter-otlp-proto-http   1.20.0
     opentelemetry-proto                      1.20.0
     opentelemetry-sdk                        1.20.0
     opentelemetry-semantic-conventions       0.41b0
     opt-einsum                               3.3.0
     ordered-set                              4.1.0
     packaging                                23.1
     pandas                                   2.2.2
     paramiko                                 3.3.1
     parso                                    0.8.3
     partd                                    1.4.1
     pathspec                                 0.11.2
     pathtools                                0.1.2
     pexpect                                  4.8.0
     Pillow                                   9.0.1
     Pillow-SIMD                              9.0.0.post1
     pip                                      24.2
     pipx                                     1.0.0
     pkginfo                                  1.10.0
     platformdirs                             3.11.0
     plotly                                   5.13.1
     pluggy                                   1.3.0
     portalocker                              2.8.2
     portpicker                               1.6.0
     pre-commit                               3.5.0
     prometheus-client                        0.17.1
     promise                                  2.3
     prompt-toolkit                           3.0.43
     protobuf                                 4.25.4
     psutil                                   5.9.5
     ptyprocess                               0.7.0
     pure-eval                                0.2.2
     py-spy                                   0.3.14
     pyarrow                                  16.1.0
     pyasn1                                   0.5.0
     pyasn1-modules                           0.3.0
     pybind11-stubgen                         2.4.2              /home/bryce/dev/pybind11-stubgen
     pycairo                                  1.20.1
     pycocotools                              2.0.7
     pycodestyle                              2.12.1
     pycparser                                2.21
     pycups                                   2.0.1
     pydantic                                 1.10.13
     pydot                                    1.4.2
     pyflakes                                 3.2.0
     pygame                                   2.5.2
     Pygments                                 2.16.1
     PyGObject                                3.42.1
     pyinotify                                0.9.6
     PyJWT                                    2.3.0
     pymacaroons                              0.13.0
     PyNaCl                                   1.5.0
     pynvml                                   11.4.1
     pyotp                                    2.9.0
     pyparsing                                2.4.7
     pyproj                                   3.6.0
     pyproject_hooks                          1.1.0
     PyQt6                                    6.5.2
     PyQt6-Qt6                                6.5.2
     PyQt6-sip                                13.5.2
     PyQt6-WebEngine                          6.5.0
     PyQt6-WebEngine-Qt6                      6.5.2
     pyquaternion                             0.9.9
     pyRFC3339                                1.1
     PySC2                                    4.0.0
     PySide2                                  5.15.2.1
     PySocks                                  1.7.1
     pytest                                   7.4.0
     python-apt                               2.4.0+ubuntu3
     python-dateutil                          2.8.2
     python-debian                            0.1.43+ubuntu1.1
     pytz                                     2022.1
     PyWavelets                               1.4.1
     pyxdg                                    0.27
     PyYAML                                   5.4.1
     pyzmq                                    25.1.2
     ray                                      2.7.1
     ray-cpp                                  2.7.1
     readme_renderer                          44.0
     referencing                              0.30.2
     regex                                    2023.10.3
     reportlab                                3.6.8
     requests                                 2.31.0
     requests-oauthlib                        1.3.1
     requests-toolbelt                        1.0.0
     retrying                                 1.3.4
     rfc3986                                  2.0.0
     rich                                     13.6.0
     rpds-py                                  0.10.6
     rsa                                      4.9
     s2clientprotocol                         5.0.13.92440.3
     s2protocol                               5.0.12.91115.0
     safetensors                              0.4.2
     sc2_serializer                           0.0.1
     scalene                                  1.5.42.2
     scikit-image                             0.20.0
     scikit-learn                             1.2.2
     scipy                                    1.10.1
     screen-resolution-extra                  0.0.0
     seaborn                                  0.12.2
     SecretStorage                            3.3.1
     sentry-sdk                               1.31.0
     setproctitle                             1.3.2
     setuptools                               67.6.0
     shapely                                  2.0.1
     shellingham                              1.5.4
     shiboken2                                5.15.2.1
     six                                      1.16.0
     sk-video                                 1.1.10
     smacv2                                   1.0.0              /home/bryce/dev/smacv2
     smart-open                               6.4.0
     smmap                                    5.0.1
     sniffio                                  1.3.0
     snowballstemmer                          2.2.0
     Sphinx                                   7.3.7
     sphinx-rtd-theme                         2.0.0
     sphinx-sitemap                           2.6.0
     sphinxcontrib-applehelp                  1.0.8
     sphinxcontrib-devhelp                    1.0.6
     sphinxcontrib-htmlhelp                   2.0.5
     sphinxcontrib-jquery                     4.1
     sphinxcontrib-jsmath                     1.0.1
     sphinxcontrib-qthelp                     1.0.7
     sphinxcontrib-serializinghtml            1.1.10
     SQLAlchemy                               2.0.32
     stack-data                               0.6.3
     starlette                                0.27.0
     structlog                                23.1.0
     sympy                                    1.11.1
     systemd-python                           234
     tabulate                                 0.9.0
     tenacity                                 8.2.3
     tensorboard                              2.17.1
     tensorboard-data-server                  0.7.2
     tensorboard-plugin-wit                   1.8.1
     tensorboardX                             2.6.2.2
     tensorflow-addons                        0.23.0
     tensorflow-estimator                     2.11.0
     tensorflow-io-gcs-filesystem             0.33.0
     tensorflow-probability                   0.19.0
     termcolor                                2.3.0
     threadpoolctl                            3.2.0
     tifffile                                 2023.9.26
     tokenizers                               0.15.2
     toml                                     0.10.2
     tomli                                    2.0.1
     toolz                                    0.12.0
     torch                                    2.4.0+cu124
     torch-discounted-sum-nd                  0.0.1
     torchaudio                               2.4.0+cu124
     torchdata                                0.7.1
     torchvision                              0.19.0+cu124
     tornado                                  6.3.3
     tqdm                                     4.66.1
     traitlets                                5.14.2
     trajdata                                 1.3.2
     transformers                             4.39.0.dev0
     trimesh                                  4.0.5
     triton                                   3.0.0
     twine                                    5.1.1
     typeguard                                2.13.3
     typer                                    0.12.4
     typing                                   3.7.4.3
     typing_extensions                        4.8.0
     tzdata                                   2023.3
     ubuntu-drivers-common                    0.0.0
     ubuntu-pro-client                        8001
     ufw                                      0.36.1
     unattended-upgrades                      0.1
     urllib3                                  1.26.16
     userpath                                 1.8.0
     uvicorn                                  0.23.2
     virtualenv                               20.21.0
     visu3d                                   1.5.1
     wadllib                                  1.3.6
     watchfiles                               0.21.0
     wcwidth                                  0.2.6
     webencodings                             0.5.1
     websocket-client                         1.6.4
     websockets                               11.0.3
     Werkzeug                                 2.2.3
     wheel                                    0.37.1
     wrapt                                    1.15.0
     xdg                                      5
     xgboost                                  2.0.3
     xkit                                     0.0.0
     xyzservices                              2023.7.0
     yacs                                     0.1.8
     yarl                                     1.9.2
     zarr                                     2.16.0
     zipp                                     1.0.0

</pre></details>

Relevant log output

Example output of the "Minimum reproducible example"

Saving image with im_data.shape=(512, 512)
NV image with nv_img.shape=(512, 512, 3)
CV default image with cv_img.shape=(512, 512, 3)
CV unchanged image with cv_img.shape=(512, 512)
PIL default image with pil_image.size=(512, 512)

Other/Misc.

No response

Check for duplicates

5had3z commented 2 weeks ago

That is some crazy scam link genration spam. GH needs to get it together lmao.

image

jantonguirao commented 2 weeks ago

It is our intention to provide 3ch by default (even if the input is 1-channel), unless specified to decode to grayscale. However, we should probably decode the original number of channels when UNCHANGED is selected. Would that behaviour be OK for you?

5had3z commented 2 weeks ago

Since this is a new library and version <1, would it be possible to change defaults to UNCHANGED (and unchanged to keep the same ch/bit depth) to minimize suprise? I don't think silent implicit conversion from one format to another should be desired behaviour.