Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Jpeg EOF

Name: Anonymous 2008-08-13 14:06

I'm trying to find out where the JPEG file ends, mainly to find out whether there's any information appended to the end of the file. I've tried searching for the EOF (FF D9), but to my surprise, this is repeated multiple times in the file in 1 out of 5 files.

Is there a way to safely determine where the JPEG file ends?

Name: Anonymous 2008-08-13 14:26

Name: Anonymous 2008-08-13 14:36

Not without actually parsing it.

Name: Anonymous 2008-08-13 14:50

That just sounds too retarded. Identifying the EOF is no problem at all in any other major format. Are there any good parsers for, say, C#?

Name: Anonymous 2008-08-13 15:20

JPEG isn't retarded, you are.

Name: Anonymous 2008-08-13 18:01

>>4
If you're using .Net, then at least use F# for your parser.

Name: Anonymous 2008-08-13 18:32

>>5
Derp.

>>6
I'll have a look at F#, thanks for the suggestion.

Name: Anonymous 2008-08-13 18:47

>>7
YHBT.

Name: Anonymous 2008-08-13 19:31

>Not without actually parsing it.

That is fucking gay.

Name: Anonymous 2008-08-13 19:56

>>1 "I've tried searching for the EOF (FF D9)"
What are you, retarded? A filesystem might use that byte sequence to mark the end of the file, but it doesn't pass it along to a program that reads the file.

Name: Anonymous 2008-08-13 20:33


char mychar;
ifstream idort;
idort.open("dicks.jpg");
while( idort.get(mychar) )
   DoShit(mychar);

Name: Anonymous 2008-08-13 20:51

to find out whether there's any information appended to the end of the file.
Hey dumbass, how about you just check whether the file ends in ffd9?

Name: Anonymous 2008-08-13 23:09

>>12
What if the appended data ends in $ffd9?

Name: Anonymous 2008-08-13 23:20

>>13
i guess the file would be corrupt

Name: Anonymous 2008-08-14 0:52

>>14
You guess poorly.

Name: Anonymous 2008-08-14 1:05

>>13
Then you've probably appended a JPEG to a JPEG. Which would probably be a stupid thing to do. And if >>1 wanted the check to be robust, tha'd just parse the file.

Name: Anonymous 2008-08-14 1:21

>>16
what about

cat file.jpg longstory.txt - < `echo -n "\0xff\0xd9"` > anotherfile.jpg

Name: Anonymous 2008-08-14 1:51

>>17
probably

Name: Anonymous 2008-08-14 7:43

file file.jpg

Name: Anonymous 2008-08-14 7:49

Nevermind, I'll just find the last FFD9 in the file and look for popular filebinder-headers while I do so.

Name: Anonymous 2008-08-14 8:02

Nevermind, I'll just hax my own anus.

Name: Anonymous 2008-08-14 9:40

Just fucking use a jpeg lib.

Name: Anonymous 2008-08-14 12:11

JPEG 2000 is fucking amazing compared to JPEG.

Name: Anonymous 2008-08-14 12:25

>>22
Pragmatic programmers? In MY /prog/?

Name: Anonymous 2008-08-14 12:53

>>24
It's more likely than you think.

Name: Anonymous 2008-08-14 13:02

Name: Anonymous 2008-08-14 13:35

>>26 DON'T CLICK IT!!!!

Name: Anonymous 2008-08-14 13:44

>>27
I clicked it just to spite you.

Name: Anonymous 2008-08-14 13:49

>>28
How was it?

Name: Anonymous 2008-08-14 13:50

>>29
Disappointing.

Name: Anonymous 2008-08-14 13:59

>>28
You're only spiting yourself.

Name: Anonymous 2008-08-14 14:47

>>31
How am I licking myself?

Name: Anonymous 2008-08-14 14:53

>>32
I would assume with your tongue.

Name: Anonymous 2008-08-14 20:32

>>1
You should parse the FF,D8 and FF,D9 pairs as you would parentheses. JPEG streams sometimes contain other JPEG streams inside them for thumbnails.

Name: Anonymous 2008-08-14 22:59

>>34
Damn, I knew there were some simple solution to it. Thanks!

Name: Anonymous 2008-08-14 23:26

##################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

Name: Anonymous 2008-08-15 3:57

So there can't be sequences FF,D8 FF,D9 anywhere in JPEG streams? Why did they do it? Simplicity of parsers?

Name: Anonymous 2008-08-15 9:36

>>37
There can be those sequences inside the JPEG stream besides the tags.

Look, it's not that difficult, you shitbag wannabes.  JPEG is a compression format.  They're not going to put any extra bytes in that can be inferred from elsewhere, nor are they going to bother with adding escape codes around FF D8|D9 pairs just so your lazy ass can grep for them.

Name: Anonymous 2008-08-15 10:49

>>38
nor are they going to bother with adding escape codes around FF D8|D9 pairs just so your lazy ass can grep for them.
Actually, remember that the JPEG bitstream format was designed by idiots. It is not sensible like PNG. From the JPEG standard:
byte stuffing: A procedure in which either the Huffman coder or the arithmetic coder inserts a zero byte into the entropy-coded segment following the generation of an encoded hexadecimal X’FF’ byte.
In order to ensure that a marker does not occur within an entropy-coded segment, any X’FF’ byte generated by either a Huffman or arithmetic encoder, or an X’FF’ byte that was generated by the padding of 1-bits described in NOTE 1 above, is followedby a “stuffed” zero byte (see D.1.6 and F.1.2.3).

Name: Anonymous 2008-08-15 11:04

>>39
0/10
learn your fucking algorithms, newbie

Name: Anonymous 2008-08-15 16:02

>>39
In particular the [b]BBCODE[/m] algorithms

Name: Anonymous 2009-03-06 8:05


The fortune You get   to PICK the   architecture and OS   X both use   and build from   whatever the hell   are you just   reminded me how   would I do   find the PHP   manual and theres   nothing in your   spare time If   there already exist   Besides im heading   back to college   and will be.

Name: Anonymous 2011-02-04 16:42

Don't change these.
Name: Email:
Entire Thread Thread List