src/PelTiff.php
public function load(PelDataWindow $d)
    {
        Pel::debug('Parsing %d bytes of TIFF data...', $d->getSize());

        /*
         * There must be at least 8 bytes available: 2 bytes for the byte
         * order, 2 bytes for the TIFF header, and 4 bytes for the offset
         * to the first IFD.
         */
        if ($d->getSize() < 8) {
            throw new PelInvalidDataException('Expected at least 8 bytes of TIFF ' . 'data, found just %d bytes.', $d->getSize());
        }
        /* Byte order */
        if ($d->strcmp(0, 'II')) {
            Pel::debug('Found Intel byte order');
            $d->setByteOrder(PelConvert::LITTLE_ENDIAN);
        } elseif ($d->strcmp(0, 'MM')) {
            Pel::debug('Found Motorola byte order');
            $d->setByteOrder(PelConvert::BIG_ENDIAN);
        } else {
            throw new PelInvalidDataException('Unknown byte order found in TIFF ' . 'data: 0x%2X%2X', $d->getByte(0), $d->getByte(1));
        }

        /* Verify the TIFF header */
        if ($d->getShort(2) != self::TIFF_HEADER) {
            throw new PelInvalidDataException('Missing TIFF magic value.');
        }
        /* IFD 0 offset */
        $offset = $d->getLong(4);
        Pel::debug('First IFD at offset %d.', $offset);

        if ($offset > 0) {
            /*
             * Parse the first IFD, this will automatically parse the
             * following IFDs and any sub IFDs.
             */
            $this->ifd = new PelIfd(PelIfd::IFD0);
            $this->ifd->load($d, $offset);
        }
    }
public function load(PelDataWindow $d)
    {
        Pel::debug('Parsing %d bytes of TIFF data...', $d->getSize());

        /*
         * There must be at least 8 bytes available: 2 bytes for the byte
         * order, 2 bytes for the TIFF header, and 4 bytes for the offset
         * to the first IFD.
         */
        if ($d->getSize() < 8) {
            throw new PelInvalidDataException('Expected at least 8 bytes of TIFF ' . 'data, found just %d bytes.', $d->getSize());
        }
        /* Byte order */
        if ($d->strcmp(0, 'II')) {
            Pel::debug('Found Intel byte order');
            $d->setByteOrder(PelConvert::LITTLE_ENDIAN);
        } elseif ($d->strcmp(0, 'MM')) {
            Pel::debug('Found Motorola byte order');
            $d->setByteOrder(PelConvert::BIG_ENDIAN);
        } else {
            throw new PelInvalidDataException('Unknown byte order found in TIFF ' . 'data: 0x%2X%2X', $d->getByte(0), $d->getByte(1));
        }

        /* Verify the TIFF header */
        if ($d->getShort(2) != self::TIFF_HEADER) {
            throw new PelInvalidDataException('Missing TIFF magic value.');
        }
        /* IFD 0 offset */
        $offset = $d->getLong(4);
        Pel::debug('First IFD at offset %d.', $offset);

        if ($offset > 0) {
            /*
             * Parse the first IFD, this will automatically parse the
             * following IFDs and any sub IFDs.
             */
            $this->ifd = new PelIfd(PelIfd::IFD0);
            $this->ifd->load($d, $offset);
        }
    }
public function load ( PelDataWindow $ d ) { Pel :: debug ( 'Parsing %d bytes of TIFF data...' , $ d -> getSize ( ) ) ; /*
         * There must be at least 8 bytes available: 2 bytes for the byte
         * order, 2 bytes for the TIFF header, and 4 bytes for the offset
         * to the first IFD.
         */ if ( $ d -> getSize ( ) < 8 ) { throw new PelInvalidDataException ( 'Expected at least 8 bytes of TIFF ' . 'data, found just %d bytes.' , $ d -> getSize ( ) ) ; } /* Byte order */ if ( $ d -> strcmp ( 0 , 'II' ) ) { Pel :: debug ( 'Found Intel byte order' ) ; $ d -> setByteOrder ( PelConvert :: LITTLE_ENDIAN ) ; } elseif ( $ d -> strcmp ( 0 , 'MM' ) ) { Pel :: debug ( 'Found Motorola byte order' ) ; $ d -> setByteOrder ( PelConvert :: BIG_ENDIAN ) ; } else { throw new PelInvalidDataException ( 'Unknown byte order found in TIFF ' . 'data: 0x%2X%2X' , $ d -> getByte ( 0 ) , $ d -> getByte ( 1 ) ) ; } /* Verify the TIFF header */ if ( $ d -> getShort ( 2 ) != self :: TIFF_HEADER ) { throw new PelInvalidDataException ( 'Missing TIFF magic value.' ) ; } /* IFD 0 offset */ $ offset = $ d -> getLong ( 4 ) ; Pel :: debug ( 'First IFD at offset %d.' , $ offset ) ; if ( $ offset > 0 ) { /*
             * Parse the first IFD, this will automatically parse the
             * following IFDs and any sub IFDs.
             */ $ this -> ifd = new PelIfd ( PelIfd :: IFD0 ) ; $ this -> ifd -> load ( $ d , $ offset ) ; } }
Load TIFF data.

The data given will be parsed and an internal tree representation
will be built. If the data cannot be parsed correctly, a {@link
PelInvalidDataException} is thrown, explaining the problem.

@param
d
PelDataWindow the data from which the object will be
constructed. This should be valid TIFF data, coming either
directly from a TIFF image or from the Exif data in a JPEG image.
Load TIFF data .