[issue16512] imghdr doesn't recognize variant jpeg formats
Martin Vignali added the comment: I'm okay with just testing the first two bytes, it's the method we currently use for our internal tools. But maybe it can be interesting, to add another test, in order to detect incomplete file (created when a camera make a recording error for example, and very useful to detect, because an incomplete jpeg file, make a crash for a lot of application) We use this patch of imghdr : -- def test_jpeg(h, f): """JPEG data in JFIF or Exif format""" if not h.startswith(b'\xff\xd8'):#Test empty files, and incorrect start of file return None else: if f:#if we test a file, test end of jpeg f.seek(-2,2) if f.read(2).endswith(b'\xff\xd9'): return 'jpeg' else:#if we just test the header, consider this is a valid jpeg and not test end of file return 'jpeg' - -- nosy: +mvignali ___ Python tracker <http://bugs.python.org/issue16512> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20295] imghdr add openexr support
New submission from Martin Vignali: Add support for detect openexr file (http://www.openexr.com/) Based on information provided by : http://www.openexr.com/ReadingAndWritingImageFiles.pdf I make some tests, on different kind of exr file, to check, the new function. -- components: Library (Lib) files: img_hdr_exr.patch keywords: patch messages: 208409 nosy: mvignali priority: normal severity: normal status: open title: imghdr add openexr support type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file33531/img_hdr_exr.patch ___ Python tracker <http://bugs.python.org/issue20295> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20295] imghdr add openexr support
Martin Vignali added the comment: New patch with formatting correction and documentation update. I'm not sure about the place of the versionadded directive in the documentation. -- Added file: http://bugs.python.org/file33547/img_hdr_exr_2.patch ___ Python tracker <http://bugs.python.org/issue20295> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20295] imghdr add openexr support
Martin Vignali added the comment: You're right, i make the correction, in a new patch. I make other tests, with official sample files : http://download.savannah.nongnu.org/releases/openexr/openexr-images-1.4.0.tar.gz -- Added file: http://bugs.python.org/file33554/img_hdr_exr_3.patch ___ Python tracker <http://bugs.python.org/issue20295> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19990] Add unittests for imghdr module
Martin Vignali added the comment: I made a simple exr file with the lib Exr (it's a half float ZIP16 RGBA file), in order to add real exr file to the unit test. When use with the patch i made here http://bugs.python.org/issue20295 , this sample file return 'exr'. Sorry, i don't know how to create an update version of your patch (i just start to use mercurial), so i just upload the sample. -- nosy: +mvignali Added file: http://bugs.python.org/file33555/python.exr ___ Python tracker <http://bugs.python.org/issue19990> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com