# Cv2.error: OpenCV(3.4.17) 👎 error: (-5:Bad argument) in function 'imwrite'

**URL:** <https://forum.opencv.org/t/cv2-error-opencv-3-4-17-error-5-bad-argument-in-function-imwrite/8754>\
**Category:** Python\
**Tags:** imgcodecs\
**Created:** [May 12, 2022, 3:42pm UTC](https://forum.opencv.org/t/cv2-error-opencv-3-4-17-error-5-bad-argument-in-function-imwrite/8754 "2022-05-12T15:42:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev1conencted](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dev1conencted](https://forum.opencv.org/u/dev1conencted)\
**Post date:** [May 12, 2022, 3:42pm UTC](https://forum.opencv.org/t/cv2-error-opencv-3-4-17-error-5-bad-argument-in-function-imwrite/8754/1 "2022-05-12T15:42:07Z")

</div>

**here s the error**

```auto

```

> Exception: Image F:\cw\bbPOV-P-main\API\NewConvert\data/Corebb.jpg could not be found for draw\_image. Check the path to the image you provided.  
> Exception: Image F:\cw\bbPOV-P-main\API\NewConvert\data/logo.jpg could not be found for draw\_image. Check the path to the image you provided.  
> F:\cw\bbPOV-P-main\API\apple.gif  
> H:\bbPOV-P\123  
> Traceback (most recent call last):  
> File “F:\cw\bbPOV-P-main\API\NewConvert\NewConvert.py”, line 72, in start\_convert  
> polarConv(frame,save\_path+‘\’+str(frameNum))  
> File “F:\cw\bbPOV-P-main\API\NewConvert\NewConvert.py”, line 57, in polarConv  
> cv2.imwrite(outputName+‘.jpg’,polar\_image,[int(cv2.IMWRITE\_JPEG\_QUALITY), 100]+[int(cv2.IMWRITE\_JPEG\_OPTIMIZE), True])  
> cv2.error: OpenCV(3.4.17) 👎 error: (-5:Bad argument) in function ‘imwrite’
> 
> > Overload resolution failed:
> > 
> > - Can’t parse ‘params’. Sequence item with index 3 has a wrong type
> > - Can’t parse ‘params’. Sequence item with index 3 has a wrong type

**This is the wrong statement**

> cv2.imwrite(outputName+‘.jpg’,polar\_image,[int(cv2.IMWRITE\_JPEG\_QUALITY), 100]+[int(cv2.IMWRITE\_JPEG\_OPTIMIZE), True])

**i try to fix it in this way**

> params = [cv2.IMWRITE\_JPEG\_QUALITY, 100, cv2.IMWRITE\_JPEG\_OPTIMIZE, 1]  
> cv2.imwrite(outputName+‘.jpg’,polar\_image, params)

**here the new error**

> Traceback (most recent call last):  
> File “G:\fansPOV\bbPOV-P-main\NewConvert.py”, line 73, in start\_convert  
> polarConv(frame,save\_path+‘\’+str(frameNum))  
> File “G:\fansPOV\bbPOV-P-main\NewConvert.py”, line 58, in polarConv  
> cv2.imwrite(outputName+‘.jpg’,polar\_image,params)  
> UnboundLocalError: local variable ‘params’ referenced before assignment

**Can anyone help me， thanks**

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 17, 2022, 8:37am UTC](https://forum.opencv.org/t/cv2-error-opencv-3-4-17-error-5-bad-argument-in-function-imwrite/8754/2 "2022-05-17T08:37:27Z")

</div>

it doesn’t like the `True` because that’s a `bool` and it expects a list of `int`.

give it `1` instead.

---

<div class="post-metadata">

**Author:** ![dev1conencted](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dev1conencted](https://forum.opencv.org/u/dev1conencted)\
**Post date:** [May 17, 2022, 9:15am UTC](https://forum.opencv.org/t/cv2-error-opencv-3-4-17-error-5-bad-argument-in-function-imwrite/8754/3 "2022-05-17T09:15:19Z")

</div>

thanks bro i got it 😀 😀
