Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Multi page imwrite for Python

Hi there, I gladly saw that a feature allowing to save multi-page images was introduced about a year ago: https://github.com/opencv/opencv/pull/10367

However I don't see this working in Python:

>>> import cv2
>>> im = cv2.imread('/tmp/test.tif')
>>> im2 = cv2.imread('/tmp/thumb.tif')
>>> cv2.imwrite([im, im2], '/tmp/opencv_multi.tif')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad argument type for built-in operation
>>> help(cv2.imwrite)
imwrite(...)
    imwrite(filename, img[, params]) -> retval
[...]

Is a Python port foreseen? Or am I just using the wrong syntax?

Thanks.

Multi page imwrite for Python

Hi there, I gladly saw that a feature allowing to save multi-page images was introduced about a year ago: https://github.com/opencv/opencv/pull/10367

However I don't see this working in Python:

>>> import cv2
>>> im = cv2.imread('/tmp/test.tif')
>>> im2 = cv2.imread('/tmp/thumb.tif')
>>> cv2.imwrite([im, im2], '/tmp/opencv_multi.tif')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad argument type for built-in operation
>>> help(cv2.imwrite)
imwrite(...)
    imwrite(filename, img[, params]) -> retval
[...]

Is a Python port foreseen? Or am I just using the wrong syntax?

Thanks.

Edit: As pointed out in the comment, the above snippet gave me a different error because of the wrong signature. With the "correct" signature I still get a TypeError though:

>>> import cv2
>>> im = cv2.imread('/tmp/test.tif')
>>> im2 = cv2.imread('/tmp/thumb.tif')
>>> cv2.imwrite([im, im2], '/tmp/opencv_multi.tif')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Expected cv::UMat for argument 'img'