# Does giving imread function a second parameter work on every image type?

**URL:** <https://forum.opencv.org/t/does-giving-imread-function-a-second-parameter-work-on-every-image-type/6735>\
**Category:** Python\
**Tags:** imgcodecs\
**Created:** [December 14, 2021, 5:08pm UTC](https://forum.opencv.org/t/does-giving-imread-function-a-second-parameter-work-on-every-image-type/6735 "2021-12-14T17:08:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Jung](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/david_jung/32/4021_2.png) [@David\_Jung](https://forum.opencv.org/u/David_Jung)\
**Post date:** [December 14, 2021, 5:08pm UTC](https://forum.opencv.org/t/does-giving-imread-function-a-second-parameter-work-on-every-image-type/6735/1 "2021-12-14T17:08:41Z")

</div>

img = cv2.imread(image\_path, cv2.IMREAD\_GRAYSCALE)

this is my code. Whatever the extension of image is, such a PNG, JPG or GIF, and regardless on whether the original image is grayscale or color image, does that code work well without errors in every cases?

- the value of second parameter doesn’t need to be cv2.IMREAD\_GRAYSCALE
- I considered an original image as only image, not video or python file.
- It’s my first question, so probably i did something wrong.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [December 14, 2021, 6:04pm UTC](https://forum.opencv.org/t/does-giving-imread-function-a-second-parameter-work-on-every-image-type/6735/2 "2021-12-14T18:04:24Z")

</div>

yes, it does.  
(why would you think, it’s not so ?)

((and, btw, the default (if you omit the flag) is IMREAD\_COLOR, which will convert _any_ image to 3 channels, whether it was so, originally, or not))

> [@David\_Jung](#):
>
> or GIF

not supported, still a patent issue

---

<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:** [December 14, 2021, 7:01pm UTC](https://forum.opencv.org/t/does-giving-imread-function-a-second-parameter-work-on-every-image-type/6735/3 "2021-12-14T19:01:43Z")

</div>

if you encounter GIF files, read them with VideoCapture.

---

<div class="post-metadata">

**Author:** ![David\_Jung](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/david_jung/32/4021_2.png) [@David\_Jung](https://forum.opencv.org/u/David_Jung)\
**Post date:** [December 15, 2021, 3:25am UTC](https://forum.opencv.org/t/does-giving-imread-function-a-second-parameter-work-on-every-image-type/6735/4 "2021-12-15T03:25:34Z")

</div>

I was just wondering if it would work in these cases:

- The given image is already **grayscle**.
- The given image extension is so unique and so different to handle that it is processed different way in cv2 library. Therefore it won’t allow to give a second parameter.
- Or Some else cases i missed.

Anyway, thank you for your **precious** comment!
