lsolesen\pel\PelIfd::setThumbnail PHP Method

setThumbnail() public method

Use this to embed an arbitrary JPEG image within this IFD. The data will be checked to ensure that it has a proper {@link PelJpegMarker::EOI} at the end. If not, then the length is adjusted until one if found. An {@link PelIfdException} might be thrown (depending on {@link Pel::$strict}) this case.
public setThumbnail ( lsolesen\pel\PelDataWindow $d )
$d lsolesen\pel\PelDataWindow the thumbnail data.
    public function setThumbnail(PelDataWindow $d)
    {
        $size = $d->getSize();
        /* Now move backwards until we find the EOI JPEG marker. */
        while ($d->getByte($size - 2) != 0xff || $d->getByte($size - 1) != PelJpegMarker::EOI) {
            $size--;
        }
        if ($size != $d->getSize()) {
            Pel::maybeThrow(new PelIfdException('Decrementing thumbnail size ' . 'to %d bytes', $size));
        }
        $this->thumb_data = $d->getClone(0, $size);
    }