Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@berak Could add this in the comment

I found code few code online using urllib and requests, which solves problem number 2

url='https://'
re=requests.get(url)
print(re.status_code)
if re.status_code == 200:
    resp = urllib.request.urlopen(url)
    image = np.asarray(bytearray(resp.read()),dtype="uint8")
    image = cv2.imdecode(image,cv2.IMREAD_COLOR)

Only part is how do I get the same None value for both corrupted as well as unsupported files that I use to get using imread

@berak Could Couldn't add this in the comment

I found code few code online using urllib and requests, which solves problem number 2

url='https://'
re=requests.get(url)
print(re.status_code)
if re.status_code == 200:
    resp = urllib.request.urlopen(url)
    image = np.asarray(bytearray(resp.read()),dtype="uint8")
    image = cv2.imdecode(image,cv2.IMREAD_COLOR)

Only part is how do I get the same None value for both corrupted as well as unsupported files that I use to get using imread

@berak Couldn't add this in the comment

I found code few code online using urllib and requests, which solves problem number 2

url='https://'
re=requests.get(url)
print(re.status_code)
if re.status_code == 200:
    resp = urllib.request.urlopen(url)
    image = np.asarray(bytearray(resp.read()),dtype="uint8")
    image = cv2.imdecode(image,cv2.IMREAD_COLOR)

Only part is how do I get the same None value for both corrupted as well as unsupported files that I use to get using imread

PS

Found this

imdecode return empty matrix/image if the buffer is short or contains invalid data hopefully None in python

According to this

image description

imread checks if the image cannot be read, then return same as decode empty martix and None in python

image description

How to I add this improper permissions, unsupported or invalid format using python on numpy array of the image I already have?

Or is it not required?

@berak Couldn't add this in the comment

I found code few code online using urllib and requests, which solves problem number 2

url='https://'
re=requests.get(url)
print(re.status_code)
if re.status_code == 200:
    resp = urllib.request.urlopen(url)
    image = np.asarray(bytearray(resp.read()),dtype="uint8")
    image = cv2.imdecode(image,cv2.IMREAD_COLOR)

Only part is how do I get the same None value for both corrupted as well as unsupported files that I use to get using imread

PS

Found this

imdecode return empty matrix/image if the buffer is short or contains invalid data hopefully None in python

According to this

image description

imread checks if the image cannot be read, then return same as decode empty martix and None in python

image description

How to I add this improper permissions, unsupported or invalid format using python on numpy array of the image I already have?

Or is it not required?