Page 1 of 1
Jpeg/Gif header information
Posted: Fri Jun 22, 2001 9:57 am
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
Jpeg/Gif header information
Posted: Fri Jun 22, 2001 10:11 am
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.
Jpeg/Gif header information
Posted: Fri Jun 22, 2001 11:21 am
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.
Jpeg/Gif header information
Posted: Fri Jun 22, 2001 11:50 am
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.