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 getExif() method is used get hold of the APP1 section which stores Exif data. So if the name of the JPEG file is stored in $filename, then one would get hold of the Exif data by saying:
The $idf0 and $ifd1 variables will then be two TIFF Image File Directories, in which the data is stored under the keys found in PelTag.
Should one have some image data (in the form of a PelDataWindow) 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 /src/PelJpeg.php (line 111)
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.
Construct a new JPEG object.
The new object will be empty unless an argument is given from which it can initialize itself. This can either be the filename of a JPEG image, a PelDataWindow object or a PHP image resource handle.
New Exif data (in the form of a PelExif object) can be inserted with the setExif() method:
Append a new section.
Used only when loading an image. If it used again later, then the section will end up after the @{link PelJpegMarker::EOI EOI marker} and will probably not be useful.
Please use @{link setExif()} instead if you intend to add Exif information to an image as that function will know the right place to insert the data.
Clear any Exif data.
This method will only clear the first @{link PelJpegMarker::APP1} section found (there should normally be just one).
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 saveFile() convenience method to do this.
Get Exif data.
Use this to get the @{link PelExif Exif data} stored.
Get a section corresponding to a particular marker.
Please use the getExif() if you just need the Exif data.
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:
Insert a new section.
Please use @{link setExif()} instead if you intend to add Exif information to an image as that function will know the right place to insert the data.
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.
Save the JPEG object as a JPEG image in a file.
Set Exif data.
Use this to set the Exif data in the image. This will overwrite any old Exif information in the image.
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 Thu, 05 May 2011 07:19:18 +0200 by phpDocumentor 1.4.3