OpenCV Image Max Pixels Limit Preventing Imports to the Client
Hydrus version
638
Qt major version
Qt 6
Operating system
Windows 11
Install method
Extract
Install and OS comments
No response
Bug description and reproduction
- Attempt to import a high resolution image
- File does not import with error
Log output
v638, 2025-09-12 17:25:24: Problem generating thumbnail for "C:\Users\***\AppData\Local\Temp\hydrus***\hydrus***".
v638, 2025-09-12 17:25:24: Extra info: File with hash "c06992e3f4b435a5ca3e8b056af1a6a6010ebb26dd72f5e2e7fcbf6fcefc4542".
v638, 2025-09-12 17:25:24:
================ Exception ================
error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:79: error: (-215:Assertion failed) pixels <= CV_IO_MAX_IMAGE_PIXELS in function 'cv::validateInputImageSize'
================ Traceback ================
Traceback (most recent call last):
File "hydrus\core\files\HydrusFileHandling.py", line 303, in GenerateThumbnailNumPy
File "hydrus\core\files\images\HydrusImageHandling.py", line 520, in GenerateThumbnailNumPyFromStaticImagePath
File "hydrus\core\files\images\HydrusImageHandling.py", line 336, in GenerateNumPyImage
cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:79: error: (-215:Assertion failed) pixels <= CV_IO_MAX_IMAGE_PIXELS in function 'cv::validateInputImageSize'
================== Stack ==================
File "threading.py", line 1032, in _bootstrap
File "threading.py", line 1075, in _bootstrap_inner
File "hydrus\core\HydrusThreading.py", line 450, in run
File "hydrus\core\HydrusThreading.py", line 1024, in Work
File "hydrus\core\HydrusThreading.py", line 952, in Work
File "hydrus\core\HydrusData.py", line 512, in __call__
File "hydrus\client\importing\ClientImportLocal.py", line 450, in REPEATINGWorkOnFiles
File "hydrus\client\importing\ClientImportLocal.py", line 204, in _WorkOnFiles
File "hydrus\client\importing\ClientImportFileSeeds.py", line 1206, in ImportPath
File "hydrus\client\importing\ClientImportFileSeeds.py", line 1171, in Import
File "hydrus\client\importing\ClientImportFiles.py", line 162, in DoWork
File "hydrus\client\importing\ClientImportFiles.py", line 332, in GenerateInfo
File "hydrus\core\files\HydrusFileHandling.py", line 307, in GenerateThumbnailNumPy
File "hydrus\core\files\HydrusFileHandling.py", line 130, in PrintMoreThumbErrorInfo
File "hydrus\core\HydrusData.py", line 318, in PrintException
File "hydrus\core\HydrusData.py", line 349, in PrintExceptionTuple
=================== End ===================
I've found that this issue only occurs in the extracted version. The installed version doesn't seem to have this problem.
Thanks. This is fascinating that the extracted version is the only one complaining. I'd normally expect them to be exactly the same since the installer really just deploys the same files as the extract with some uninstall metadata. Maybe there's an unusual environment issue related to install location or maybe an old .dll file from a previous install that is being loaded and causing trouble.
For the actual problem, I have a hook for PIL, our other image library, for exactly this 'I won't load bigger than x' issue, but I haven't encountered it with OpenCV before. A little research suggests CV_IO_MAX_IMAGE_PIXELS defaults to 2^30, or about a gigapixel (so, if it is 24bit, 3GB canvas)! Are you importing something around 32kx32k?
I tried to create a test image in Gimp and it gave me the old meme joke about 'you are trying to create an image with size 23GB', hahaha.
I'm seeing that some people are able to break the limit by setting:
CV_IO_MAX_IMAGE_PIXELS=4294967296
Environment variable before loading their program/CV, but it seems like it doesn't work for everyone for every version. If you know how to set an environment variable before launching a program in Windows, can you try this?
Can you also, in your two installs, check the value of the 'load images with PIL' setting under options->media playback? Should be right at the bottom of the panel. We've been toying with moving away from CV entirely, so I wonder if your 'install' install is older than the extract and still has that setting set off for some legacy reason. If you can turn it on, does it fix the issue?
This issue does not appear anymore on v678 and possibly few versions prior. Apologies for the late update.