# How do figure out the endianness of a JPG?

**URL:** <https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570>\
**Category:** Factual Questions\
**Created:** [October 4, 2004, 11:45pm UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570 "2004-10-04T23:45:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawdirk](https://avatars.discourse-cdn.com/v4/letter/j/df705f/32.png) [@jawdirk](https://boards.straightdope.com/u/jawdirk)\
**Post date:** [October 4, 2004, 11:45pm UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/1 "2004-10-04T23:45:07Z")

</div>

Is there an easy method, using a Hex-editor, say, to discover the endianness of a JPG?

Thanks.

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [October 5, 2004, 2:40am UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/2 "2004-10-05T02:40:15Z")

</div>

Didn’t know it varied. I’ve never had a graphic program offer me the option, or something likely to be its equivalent (i.e., “Windows byte-order” versus “Mac byte-order” or something akin to that).

What would cause a JPEG to be little-endianned as opposed to big-endianned in the first place?

Or are you asking, not for “a given JPEG”, but rather “for all JPEGs in general”, i.e., “what’s the standard byte-order of these puppies”?

---

<div class="post-metadata">

**Author:** ![Bytegeist](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@Bytegeist](https://boards.straightdope.com/u/Bytegeist)\
**Post date:** [October 5, 2004, 3:10am UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/3 "2004-10-05T03:10:33Z")

</div>

According to [this guy](http://www.cs.umass.edu/~verts/cs32/endian.html), as well as several other pages covering the format, the integer fields inside a JPEG file are all big-endian. (The most significant bytes precede the less significant ones).

---

<div class="post-metadata">

**Author:** ![Muffin](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/muffin/32/4341_2.png) [@Muffin](https://boards.straightdope.com/u/Muffin)\
**Post date:** [October 5, 2004, 3:44am UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/4 "2004-10-05T03:44:04Z")

</div>

Status or non-status?

---

<div class="post-metadata">

**Author:** ![astro](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@astro](https://boards.straightdope.com/u/astro)\
**Post date:** [October 5, 2004, 10:19am UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/5 "2004-10-05T10:19:39Z")

</div>

[A Sample JPEG Image File Data structure.](http://www.geocities.com/tapsemi/datastruct.html)

[JPEG / JFIF image file format](http://www.geocities.com/marcoschmidt.geo/jpeg-image-file-format.html)

> [@](#):
>
> File structure  
> A JPEG bitstream is a sequence of data chunks, each chunk starts with a marker value. A marker is a 16 bit integer value, **stored in big endian byte order** , with the most significant byte set to 0xff. The lower byte of the marker value determines its type. A marker is followed by a 16 bit integer value for the size.

---

<div class="post-metadata">

**Author:** ![Polycarp](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Polycarp](https://boards.straightdope.com/u/Polycarp)\
**Post date:** [October 5, 2004, 1:56pm UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/6 "2004-10-05T13:56:47Z")

</div>

So a corrupted JPEG file could be referred to as Blefuscated? 😛

---

<div class="post-metadata">

**Author:** ![jawdirk](https://avatars.discourse-cdn.com/v4/letter/j/df705f/32.png) [@jawdirk](https://boards.straightdope.com/u/jawdirk)\
**Post date:** [October 5, 2004, 5:43pm UTC](https://boards.straightdope.com/t/how-do-figure-out-the-endianness-of-a-jpg/267570/7 "2004-10-05T17:43:40Z")

</div>

Thanks for all your answers. That is very helpful.

Andrew
