FAQ
Hi,

I have 206 jpg files. And imghdr.what returns 'None' for 52 of them,
and I found that actually those 52 files can be viewed perfectly with
an image viewer (xnview), and xnview also identifed them as JPEG
TrueColor(v1.1) in the File Properties.

Is it true that the jpg file format has more than one "identifying
signature" which the imghdr.what function didn't yet incorporate, and
hence the false negatives?

Thanks!

Search Discussions

  • Steven Taschuk at Jun 8, 2003 at 5:14 am

    Quoth Arsenal:
    I have 206 jpg files. And imghdr.what returns 'None' for 52 of them,
    and I found that actually those 52 files can be viewed perfectly with
    an image viewer (xnview), and xnview also identifed them as JPEG
    TrueColor(v1.1) in the File Properties.

    Is it true that the jpg file format has more than one "identifying
    signature" which the imghdr.what function didn't yet incorporate, and
    hence the false negatives?
    That seems a reasonable guess.

    A glance at the source shows that imghdr.what identifies JPEGs
    this way:
    if h[6:10] == 'JFIF':
    That is, the test is whether bytes 6 through 9 inclusive of the
    file are 'JFIF'. (As the documentation notes, it identifies JPEGs
    in JFIF format specifically.)

    Do your files have this property? If not, what are these bytes?

    (My magic(4), for comparison, identifies JPEGs thus:
    0 beshort 0xffd8 JPEG image data
    6 string JFIF \b, JFIF standard
    6 string Exif \b, EXIF standard
    )

    --
    Steven Taschuk staschuk at telusplanet.net
    "I'm always serious, never more so than when I'm being flippant."
    -- _Look to Windward_, Iain M. Banks
  • Arsenal at Jun 8, 2003 at 11:18 am
    Steven Taschuk <staschuk at telusplanet.net> wrote in message news:<mailman.1055048975.23465.python-list at python.org>...
    Quoth Arsenal:
    I have 206 jpg files. And imghdr.what returns 'None' for 52 of them,
    and I found that actually those 52 files can be viewed perfectly with
    an image viewer (xnview), and xnview also identifed them as JPEG
    TrueColor(v1.1) in the File Properties.

    Is it true that the jpg file format has more than one "identifying
    signature" which the imghdr.what function didn't yet incorporate, and
    hence the false negatives?
    That seems a reasonable guess.

    A glance at the source shows that imghdr.what identifies JPEGs
    this way:
    if h[6:10] == 'JFIF':
    That is, the test is whether bytes 6 through 9 inclusive of the
    file are 'JFIF'. (As the documentation notes, it identifies JPEGs
    in JFIF format specifically.)

    Do your files have this property? If not, what are these bytes?

    (My magic(4), for comparison, identifies JPEGs thus:
    0 beshort 0xffd8 JPEG image data
    6 string JFIF \b, JFIF standard
    6 string Exif \b, EXIF standard
    )
    Thanks for your info.

    Bytes [6:10] for my 52 jpg files are 'Exif'. So if imghdr.what adds
    this additonal check, all of my jpgs would be correctly identified.

    Anyways, I have used the Python Image Library (PIL) instead, which
    supports a lot more image format and pretty fast too.
  • Steven Taschuk at Jun 8, 2003 at 3:39 pm
    Quoth Arsenal:
    [...]
    Bytes [6:10] for my 52 jpg files are 'Exif'. So if imghdr.what adds
    this additonal check, all of my jpgs would be correctly identified.
    That would be easy enough to implement, but I really have no idea
    whether it would be the Right Thing.

    The docs explicitly say that 'jpeg' is returned for JFIF JPEGs;
    not, that implies, for EXIF JPEGs. I don't know what the
    differences between these standards are, nor whether or to what
    extent imghdr.what ought to be sensitive to the distinction.

    --
    Steven Taschuk w_w
    staschuk at telusplanet.net ,-= U
    1 1
  • Terry Reedy at Jun 8, 2003 at 6:59 pm
    "Steven Taschuk" <staschuk at telusplanet.net> wrote in message
    news:mailman.1055086335.1441.python-list at python.org...
    Quoth Arsenal:
    [...]
    Bytes [6:10] for my 52 jpg files are 'Exif'. So if imghdr.what
    adds
    this additonal check, all of my jpgs would be correctly
    identified.
    That would be easy enough to implement, but I really have no idea
    whether it would be the Right Thing.

    The docs explicitly say that 'jpeg' is returned for JFIF JPEGs;
    not, that implies, for EXIF JPEGs. I don't know what the
    differences between these standards are, nor whether or to what
    extent imghdr.what ought to be sensitive to the distinction.
    This strikes me as something reasonable to submit an SF patch or bug
    report for.

    TJR
  • Steven Taschuk at Jun 8, 2003 at 8:21 pm
    Quoth Terry Reedy:
    [...]
    This strikes me as something reasonable to submit an SF patch or bug
    report for.
    <http://www.python.org/sf/751031>

    --
    Steven Taschuk staschuk at telusplanet.net
    Receive them ignorant; dispatch them confused. (Weschler's Teaching Motto)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 8, '03 at 1:03a
activeJun 8, '03 at 8:21p
posts6
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase