src/PelJpeg.php
public function getBytes()
    {
        $bytes = '';

        foreach ($this->sections as $section) {
            $m = $section[0];
            $c = $section[1];

            /* Write the marker */
            $bytes .= "\xFF" . PelJpegMarker::getBytes($m);
            /* Skip over empty markers. */
            if ($m == PelJpegMarker::SOI || $m == PelJpegMarker::EOI) {
                continue;
            }

            $data = $c->getBytes();
            $size = strlen($data) + 2;

            $bytes .= PelConvert::shortToBytes($size, PelConvert::BIG_ENDIAN);
            $bytes .= $data;

            /* In case of SOS, we need to write the JPEG data. */
            if ($m == PelJpegMarker::SOS) {
                $bytes .= $this->jpeg_data->getBytes();
            }
        }

        return $bytes;
    }
public function getBytes()
    {
        $bytes = '';

        foreach ($this->sections as $section) {
            $m = $section[0];
            $c = $section[1];

            /* Write the marker */
            $bytes .= "\xFF" . PelJpegMarker::getBytes($m);
            /* Skip over empty markers. */
            if ($m == PelJpegMarker::SOI || $m == PelJpegMarker::EOI) {
                continue;
            }

            $data = $c->getBytes();
            $size = strlen($data) + 2;

            $bytes .= PelConvert::shortToBytes($size, PelConvert::BIG_ENDIAN);
            $bytes .= $data;

            /* In case of SOS, we need to write the JPEG data. */
            if ($m == PelJpegMarker::SOS) {
                $bytes .= $this->jpeg_data->getBytes();
            }
        }

        return $bytes;
    }
public function getBytes ( ) { $ bytes = '' ; foreach ( $ this -> sections as $ section ) { $ m = $ section [ 0 ] ; $ c = $ section [ 1 ] ; /* Write the marker */ $ bytes .= "\xFF" . PelJpegMarker :: getBytes ( $ m ) ; /* Skip over empty markers. */ if ( $ m == PelJpegMarker :: SOI || $ m == PelJpegMarker :: EOI ) { continue ; } $ data = $ c -> getBytes ( ) ; $ size = strlen ( $ data ) + 2 ; $ bytes .= PelConvert :: shortToBytes ( $ size , PelConvert :: BIG_ENDIAN ) ; $ bytes .= $ data ; /* In case of SOS, we need to write the JPEG data. */ if ( $ m == PelJpegMarker :: SOS ) { $ bytes .= $ this -> jpeg_data -> getBytes ( ) ; } } return $ bytes ; }
Turn this JPEG object into bytes.

The bytes returned by this method is ready to be stored in a file
as a valid JPEG image. Use the {@link saveFile()} convenience
method to do this.

@return string bytes representing this JPEG object, including all
its sections and their associated data.
Turn this JPEG object into bytes .