Is there any other way to save an image in opencv with python without “imwrite” function?
where is the problem with it ? please explain
I am new to opencv. I wanted to know if there is any method to save an image at a location without using “imwrite” function directly
why dont you want to use it ?
Bro, instead of asking me these many questions, you could have given the answer
i’m not yor bro, and you just keep repeating yourself
what you are asking is unusual and frankly pointless. OpenCV has a function to write pictures. use it. if you don’t want to use it, you should explain why you want something else.
if you don’t understand why that is, the fault lies with you.
As I know
OpenCV has only
You can also use
imdecode() with standard
write() but it will do the same as
result, data = cv2.imencode('.jpg', img) fh = open('output-imencode.jpg', 'wb') fh.write(data) fh.close()
For other method you have to install external module.
You can write it with
imageio - but remeber to conver image from
import imageio img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) imageio.imwrite('output-imageio.jpg', img)
You can also conver to
PILLOW and write it. It also need to convert
from PIL import Image img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = Image.fromarray(img) img.save('output-pillow.jpg')
Thanks for the information. I have one more query, I saw people in the internet calling the output of imencode function as buffer. I know that buffer is a memory allocated for something. But here from imencode function, we are getting stream of bytes. So how is it related to buffer?
Reference link : python - Interpreting cv2.imencode result - Stack Overflow