Class for handling JPEG data.
The PelJpeg class defined here provides an abstraction for dealing with a JPEG file. The file will be contain a number of sections containing some content identified by a marker.
The getSection() method is used to pick out a particular section --- the EXIF information is typically stored in the APP1 section, and so one would get hold of it by saying:
- $jpeg = new PelJpeg($data);
- $app1 = $jpeg->getSection(PelJpegMarker::APP1);
- $tiff = $app1->getTiff();
- $ifd0 = $tiff->getIfd();
- $exif = $ifd0->getSubIfd(PelTag::EXIF_IFD_POINTER);
- $ifd1 = $ifd0->getNextIfd();
Should one have some image data of an unknown type, then the PelJpeg::isValid() function is handy: it will quickly test if the data could be valid JPEG data. The PelTiff::isValid() function does the same for TIFF images.
Located in /PelJpeg.php (line 104)
Construct a new JPEG object.
The new object will be empty, use the load() or loadFile() methods to load JPEG data from a PelDataWindow or a file, respectively.
Individual sections of JPEG content can be added with the appendSection() method --- use this method to add a PelExif object as the PelJpegMarker::APP1 section of an existing file without EXIF information:
- $jpeg = new PelJpeg();
- $jpeg->load($data);
- $jpeg->appendSection($exif, PelJpegMarker::APP1);
Add a new section.
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.
Get a sections corresponding to a particular marker.
This will search through the sections of this JPEG object, looking for a section identified with the specified marker. The content will then be returned. The optional argument can be used to skip over some of the sections. So if one is looking for the, say, third DHT section one would do:
- $dht3 = $jpeg->getSection(PelJpegMarker::DHT, 2);
whereas one can just do:
- $app1 = $jpeg->getSection(PelJpegMarker::APP1);
to get hold of the first (and normally only) APP1 section, which would hold the EXIF data.
Insert a new section.
Test data to see if it could be a valid JPEG image.
The function will only look at the first few bytes of the data, and try to determine if it could be a valid JPEG image based on those bytes. This means that the check is more like a heuristic than a rigorous check.
Load data into a JPEG object.
The data supplied will be parsed and turned into an object structure representing the image. This structure can then be manipulated and later turned back into an string of bytes.
This methods can be called at any time after a JPEG object has been constructed, also after the appendSection() has been called to append custom sections. Loading several JPEG images into one object will accumulate the sections, but there will only be one PelJpegMarker::SOS section at any given time.
Load data from a file into a JPEG object.
Make a string representation of this JPEG object.
This is mainly usefull for debugging. It will show the structure of the image, and its sections.
Documentation generated on Wed, 21 Jul 2004 19:13:12 +0200 by phpDocumentor 1.3.0RC3