protected function parseExifIfd()
{
$byte_order = $this->stream->read(2);
switch ($byte_order) {
case 'II':
$this->short = 'v';
$this->long = 'V';
break;
case 'MM':
$this->short = 'n';
$this->long = 'N';
break;
default:
throw new Faster_Image_B52f1a8_Invalid_Image_Exception();
break;
}
$this->stream->read(2);
$offset = current(unpack($this->long, $this->stream->read(4)));
$this->stream->read($offset - 8);
$tag_count = current(unpack($this->short, $this->stream->read(2)));
for ($i = $tag_count; $i > 0; $i--) {
$type = current(unpack($this->short, $this->stream->read(2)));
$this->stream->read(6);
$data = current(unpack($this->short, $this->stream->read(2)));
switch ($type) {
case 0x100:
$this->width = $data;
break;
case 0x101:
$this->height = $data;
break;
case 0x112:
$this->orientation = $data;
break;
}
if (isset($this->width) && isset($this->height) && isset($this->orientation)) {
return true;
}
$this->stream->read(2);
}
return false;
}