Image_JpegMarkerReader
[ class tree: Image_JpegMarkerReader ] [ index: Image_JpegMarkerReader ] [ all elements ]

Class: Image_JpegMarkerReader

Source Location: /Image_JpegMarkerReader-0.5.0/JpegMarkerReader.php

Class Overview


Read markers from a JPEG file with reasonable efficiency.


Author(s):

Copyright:

  • 2008 P'unk Avenue LLC

Methods


Inherited Variables

Inherited Methods


Class Details

[line 56]
Read markers from a JPEG file with reasonable efficiency.


[ Top ]


Method Detail

__construct (Constructor)   [line 121]

Image_JpegMarkerReader __construct( string $filename)

Creates a new Image_JpegMarkerReader object which will read from the specified file
  • Access: public

Parameters:

string   $filename   —  file to open

[ Top ]

__destruct (Destructor)   [line 149]

void __destruct( )

Automatically closes the file, if it is open
  • Access: public

[ Top ]

isAtImageData   [line 250]

boolean isAtImageData( )

Returns true if the start of the entropy-coded image data

has been reached. Note that if setReadPastImageData has been called with a true value this point may be reached and then skipped past depending on what markers are asked for, in which case this method will return false. In most cases you won't care whether isEof or isAtImageData returns true, but if you really want to know you can tell the difference.

  • Access: public

[ Top ]

isEof   [line 234]

boolean isEof( )

Returns true if the end of the file has been encountered

After a 'false' return from readMarker or readNextMarker, This function can be used to determine whether the end of the file has been encountered. EOF (or the start of image data) is also indicated by a false return from readMarker or readNextMarker (as opposed to an actual error condition, such as a damaged file, which throws a JpegMarkerReaderException).

  • Access: public

[ Top ]

readMarker   [line 179]

boolean|string readMarker( integer $m)

Locates and returns the next instance of the desired marker type

Scans through the JPEG file until a marker of the specified type is encountered. JPEG marker types consist of two bytes: 0xFF, and a second byte which identifies that particular marker. Pass only the second byte, as an integer. See the JpegXmpReader package for an example of usage.

If the marker is not found before EOF, returns false (test for this with === false). On success, returns the data for the specified marker, as a string.

Note that some marker types can occur more than once in a single file. You may call readMarker again if, after examining the data, you determine that it is not the marker you wanted or you simply wish to fetch another.

  • Access: public

Parameters:

integer   $m   —  Marker byte, as an integer

[ Top ]

readNextMarker   [line 216]

boolean|array readNextMarker( )

Reads and returns the next marker, regardless of marker type

When you really want the next marker no matter what it is. On EOF, returns false (just false, not an array). On success, returns an array of two elements: the marker type (as an integer) and the marker data (as a string).

If the marker is a _standalone marker which, by definition, has no data associated with it, the second element of the array will be set to false.

  • Access: public

[ Top ]

setReadPastImageData   [line 141]

none setReadPastImageData( boolean $readPastImageData)

By default, Image_JpegMarkerReader will return the SOS marker (0xDA) as the last marker and begin indicating EOF at that point.

If this method is called with readPastImageData set to true, Image_JpegMarkerReader will skip over the actual entropy-coded image data (a very slow operation) to look for markers at the very end of the file, such as (and probably limited to) EOI.

You don't want to do this unless you absolutely have to.

  • Access: public

Parameters:

boolean   $readPastImageData   —  set to true if markers after image data are considered interesting (warning: slow)

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:23:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.