lsolesen\pel\PelTiff::getBytes PHP Method

getBytes() public method

TIFF images can have {@link PelConvert::LITTLE_ENDIAN little-endian} or {@link PelConvert::BIG_ENDIAN big-endian} byte order, and so this method takes an argument specifying that.
public getBytes ( PelByteOrder $order = PelConvert::LITTLE_ENDIAN ) : string
$order PelByteOrder the desired byte order of the TIFF data. This should be one of {@link PelConvert::LITTLE_ENDIAN} or {@link PelConvert::BIG_ENDIAN}.
return string the bytes representing this object.
    public function getBytes($order = PelConvert::LITTLE_ENDIAN)
    {
        if ($order == PelConvert::LITTLE_ENDIAN) {
            $bytes = 'II';
        } else {
            $bytes = 'MM';
        }
        /* TIFF magic number --- fixed value. */
        $bytes .= PelConvert::shortToBytes(self::TIFF_HEADER, $order);
        if ($this->ifd !== null) {
            /*
             * IFD 0 offset. We will always start IDF 0 at an offset of 8
             * bytes (2 bytes for byte order, another 2 bytes for the TIFF
             * header, and 4 bytes for the IFD 0 offset make 8 bytes
             * together).
             */
            $bytes .= PelConvert::longToBytes(8, $order);
            /*
             * The argument specifies the offset of this IFD. The IFD will
             * use this to calculate offsets from the entries to their data,
             * all those offsets are absolute offsets counted from the
             * beginning of the data.
             */
            $bytes .= $this->ifd->getBytes(8, $order);
        } else {
            $bytes .= PelConvert::longToBytes(0, $order);
        }
        return $bytes;
    }