Python – Getting error – ‘could not find a writer’while giving imshow, imwrite command opencv


I am a beginner at opencv and python.
I have just installed opencv2.4.9 and enthought canopy-32bit. I am getting error for the following:

import cv2
image = cv2.imread('Lena.jpg')

This is what I get:

c:\users\nam\appdata\local\temp\ in <module>()
      4 image = cv2.imread('Lena.jpg')
----> 5 cv2.imwrite('Mypic',image)

error: ..\..\..\..\opencv\modules\highgui\src\loadsave.cpp:275: error: (-2) could not find a writer for the specified extension in function cv::imwrite_

Best Solution

you need to give an extension to imwrite(), so it knows, how to save(compress) it.

# jpg,bmp,png,ppm,pgm,tiff supported 'out-of-the-box,
# webp,jp2 depending on if you compiled in the resp. 3rd party support
# no gif or tga.
Related Question