On 12 Mar 2007 at 9:34, Tom Phoenix wrote:
> On 3/12/07, Beginner <[EMAIL PROTECTED]> wrote:
>
> > When I ask for the filehandle position (tell) it is reporting the
> > pointer as being a few bytes further along than I expect it to be.
>
> > binmode(FH);
> >
> > while (<FH>) {
>
> If it's a binary file, you shouldn't read it by "lines", which is what
> this does. You should probably use the read function instead; that
> will let you specify how many bytes to read at a time. (And is a while
> loop the right construct for the operation you're performing?)
Obviously not. I fthink this is more what I should be using to read 4
bytes at a time:
while (read FH, $buf, 4) {
> > if ($_ =~ /\xFF\xC0/) { # Start of frame header.
> > print "Found start of frame at $start\n";
>
> Where did you put a value into $start?
Yes some over zealous editing on my part. I was trying to snip out
all the irrelevant stuff and removed
$start = tell FH;
> Finally, it looks as if you're looking into the data of a jpeg/jfif
> file. Isn't there a module that will help you do what you want without
> mucking around in the raw bytes?
I must admit Tom, you are good. I am indeed looking for a the jpeg
Start Of Frame marker. When I started writing the last post I did do
a preamble about re-inventing the wheel but that got chopped too.
What I am tring to do is find the x and y dimension of a jpeg which
can be found in the first few bytes of the header. ImageMagick or
similar would do this but I am trying to help a friend who has to get
the dimension so he can work out the uncompressed size of the file
(x_axis x y_axis x 3 /1024 /1024). He doesn't have access to perl or
c libraries and will have to read the file in byte by byte to
determine the size of the file and it's a good lesson in binary
reading for me too :-)
> Hope this helps!
You haven't failed yet!
> --Tom Phoenix
> Stonehenge Perl Training
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/