Jpeg/Gif header information

Post Reply
sabety
Posts: 76
Joined: Wed Dec 06, 2000 7:11 am

Jpeg/Gif header information

Post by sabety »

Does anyone have vortex code for reading jpeg or gif headers and pulling out the image dimensions?

I can't seem to find a vortex function that will read markers from the files at certain byte offsets and keep moving until it gets to the start of frame segment with the image height and width info. I would hate to resort to a c program if vortex can do it...

thanks
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Jpeg/Gif header information

Post by mark »

vortex <read> can read a specific amount of data from a specific offset of a file. See http://www.thunderstone.com/site/vortexman/node100.html

Or you could read the whole header in and use <substr> to get desired portions.

You can use strfmt's %!c to turn the binary values into something you can use in vortrex.
sabety
Posts: 76
Joined: Wed Dec 06, 2000 7:11 am

Jpeg/Gif header information

Post by sabety »

That's great thanks Mark.

Now that I have found the bit of the header I want, in this case the FFC0 marker in a JPEG file, how do I get to the stuff after it and before the next marker? The strfmt %!c seems to stop at null values in the binary data... and I can't seem to read offsets past a null value.
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Jpeg/Gif header information

Post by Kai »

<strfmt "%!c"> only takes the first byte of its argument, since it only prints 1 ASCII value. <substr>, however, like its C counterpart, stops at nul in strings. You can use <rex> to pull out specific parts of a binary string without stopping at nul, since <rex> is full binary compatible:

<rex ">>=....\P=.." $data>

would be equivalent to:

<substr $data 4 2>

without stopping at nul.
Post Reply