'TypeError: imwrite() takes 2 positional arguments but 3 were given

I am trying to save jpg image with quality 80 by opencv. Here is the python script I tried:

cv2.imwrite(isdocker.DOCKER_PREFIX + IM.path + IM.name, IM.data, [(int(cv2.IMWRITE_JPEG_QUALITY),80)])

It pops up with an error 'TypeError: imwrite() takes 2 positional arguments but 3 were given'. I know a similar post in here. But I think its different issue. I have read the documentation from opencv and it seems they have changed something. Please help me.

Additional Information:Python 3.9.7 (default, May 19 2022, 00:53:30) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.version '4.5.5'



Solution 1:[1]

You almost have it. The third parameter is the codec's compression parameters, and it is given as a list of integers (not a list of tuples). Like this:

cv2.imwrite(imagePath, inputImage, [cv2.IMWRITE_JPEG_QUALITY, 80])

Solution 2:[2]

It is common issue i used to get when using action mailer with google SMTP configuration. I used to fellow below few step to solve it.

  1. Try to login to google account manually with same location where rails server is there and check if captcha is showing.
  2. Once Mail working from rails sever never login manually to goole account again.
  3. Try changing authentication: :plain to :login

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 stateMachine
Solution 2 GAURAV SETH