classification
Title: Imghdr doesnt recognise some jpeg
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: Krishna Oza, pchopin, vstinner
Priority: normal Keywords:

Created on 2019-07-19 09:50 by pchopin, last changed 2019-09-11 14:00 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
e2006bd7-51d7-4554-9738-ea13207fd104.jpg pchopin, 2019-07-19 09:50
cpython_imghdr_issue.txt Krishna Oza, 2019-07-19 13:04
Pull Requests
URL Status Linked Edit
PR 15955 open python-dev, 2019-09-11 14:00
Messages (4)
msg348161 - (view) Author: Pierre Chopin (pchopin) * Date: 2019-07-19 09:50
the imghdr library only checks for the presence of (b'JFIF', b'Exif') in the header, which is excluding some valid JPEG file. This is an example of not recognised ile
msg348171 - (view) Author: Krishna Oza (Krishna Oza) * Date: 2019-07-19 12:19
The documentation at https://docs.python.org/3/library/imghdr.html?highlight=imghdr#module-imghdr says that JPEG files with JPEG data in JFIF or Exif formats are only supported as of now. Pierre Chopin could help with what format of jpeg you have uploaded.
msg348173 - (view) Author: Krishna Oza (Krishna Oza) * Date: 2019-07-19 13:04
Victor
I have debugged the issue and found that the jpg file shared doesnt have the information in its header to identify the file format of this file.
The imghdr module needs file format information in first 32 bytes when the jpg file is read in binary mode. However for the  file "e2006bd7-51d7-4554-9738-ea13207fd104.jpg" there is no such information present and hence I would like to suggest that the issue be closed appropriately.

P.S. Attaching the dump of file "e2006bd7-51d7-4554-9738-ea13207fd104.jpg" when read in binary mode.
msg348179 - (view) Author: Pierre Chopin (pchopin) * Date: 2019-07-19 14:21
This is actually a duplicate of bpo-16512, i am closing this.
History
Date User Action Args
2019-09-11 14:00:27python-devsetpull_requests: + pull_request15590
2019-07-19 14:21:41pchopinsetstatus: open -> closed
resolution: duplicate
messages: + msg348179

stage: resolved
2019-07-19 13:04:46Krishna Ozasetfiles: + cpython_imghdr_issue.txt
nosy: + vstinner
messages: + msg348173

2019-07-19 12:47:19Krishna Ozasettype: behavior
components: + Library (Lib)
2019-07-19 12:19:02Krishna Ozasetnosy: + Krishna Oza
messages: + msg348171
2019-07-19 09:50:28pchopincreate