X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FExif.php;h=cd457f0beca125f17a0c689e8283983150197e84;hb=50ea235528289fa3b7b31a2281c6c7683053b7f4;hp=95fa8594fc0f0f235ca43c20efa91de2562d2398;hpb=171255101f2a6480f237f54af64bc29d8ce50ac3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/Exif.php b/includes/media/Exif.php index 95fa8594fc..cd457f0bec 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -96,8 +96,6 @@ class Exif { private $byteOrder; /** - * Constructor - * * @param string $file Filename. * @param string $byteOrder Type of byte ordering either 'BE' (Big Endian) * or 'LE' (Little Endian). Default ''. @@ -120,162 +118,162 @@ class Exif { # TIFF Rev. 6.0 Attribute Information (p22) 'IFD0' => [ # Tags relating to image structure - 'ImageWidth' => Exif::SHORT_OR_LONG, # Image width - 'ImageLength' => Exif::SHORT_OR_LONG, # Image height - 'BitsPerSample' => [ Exif::SHORT, 3 ], # Number of bits per component + 'ImageWidth' => self::SHORT_OR_LONG, # Image width + 'ImageLength' => self::SHORT_OR_LONG, # Image height + 'BitsPerSample' => [ self::SHORT, 3 ], # Number of bits per component # "When a primary image is JPEG compressed, this designation is not" # "necessary and is omitted." (p23) - 'Compression' => Exif::SHORT, # Compression scheme #p23 - 'PhotometricInterpretation' => Exif::SHORT, # Pixel composition #p23 - 'Orientation' => Exif::SHORT, # Orientation of image #p24 - 'SamplesPerPixel' => Exif::SHORT, # Number of components - 'PlanarConfiguration' => Exif::SHORT, # Image data arrangement #p24 - 'YCbCrSubSampling' => [ Exif::SHORT, 2 ], # Subsampling ratio of Y to C #p24 - 'YCbCrPositioning' => Exif::SHORT, # Y and C positioning #p24-25 - 'XResolution' => Exif::RATIONAL, # Image resolution in width direction - 'YResolution' => Exif::RATIONAL, # Image resolution in height direction - 'ResolutionUnit' => Exif::SHORT, # Unit of X and Y resolution #(p26) + 'Compression' => self::SHORT, # Compression scheme #p23 + 'PhotometricInterpretation' => self::SHORT, # Pixel composition #p23 + 'Orientation' => self::SHORT, # Orientation of image #p24 + 'SamplesPerPixel' => self::SHORT, # Number of components + 'PlanarConfiguration' => self::SHORT, # Image data arrangement #p24 + 'YCbCrSubSampling' => [ self::SHORT, 2 ], # Subsampling ratio of Y to C #p24 + 'YCbCrPositioning' => self::SHORT, # Y and C positioning #p24-25 + 'XResolution' => self::RATIONAL, # Image resolution in width direction + 'YResolution' => self::RATIONAL, # Image resolution in height direction + 'ResolutionUnit' => self::SHORT, # Unit of X and Y resolution #(p26) # Tags relating to recording offset - 'StripOffsets' => Exif::SHORT_OR_LONG, # Image data location - 'RowsPerStrip' => Exif::SHORT_OR_LONG, # Number of rows per strip - 'StripByteCounts' => Exif::SHORT_OR_LONG, # Bytes per compressed strip - 'JPEGInterchangeFormat' => Exif::SHORT_OR_LONG, # Offset to JPEG SOI - 'JPEGInterchangeFormatLength' => Exif::SHORT_OR_LONG, # Bytes of JPEG data + 'StripOffsets' => self::SHORT_OR_LONG, # Image data location + 'RowsPerStrip' => self::SHORT_OR_LONG, # Number of rows per strip + 'StripByteCounts' => self::SHORT_OR_LONG, # Bytes per compressed strip + 'JPEGInterchangeFormat' => self::SHORT_OR_LONG, # Offset to JPEG SOI + 'JPEGInterchangeFormatLength' => self::SHORT_OR_LONG, # Bytes of JPEG data # Tags relating to image data characteristics - 'TransferFunction' => Exif::IGNORE, # Transfer function - 'WhitePoint' => [ Exif::RATIONAL, 2 ], # White point chromaticity - 'PrimaryChromaticities' => [ Exif::RATIONAL, 6 ], # Chromaticities of primarities + 'TransferFunction' => self::IGNORE, # Transfer function + 'WhitePoint' => [ self::RATIONAL, 2 ], # White point chromaticity + 'PrimaryChromaticities' => [ self::RATIONAL, 6 ], # Chromaticities of primarities # Color space transformation matrix coefficients #p27 - 'YCbCrCoefficients' => [ Exif::RATIONAL, 3 ], - 'ReferenceBlackWhite' => [ Exif::RATIONAL, 6 ], # Pair of black and white reference values + 'YCbCrCoefficients' => [ self::RATIONAL, 3 ], + 'ReferenceBlackWhite' => [ self::RATIONAL, 6 ], # Pair of black and white reference values # Other tags - 'DateTime' => Exif::ASCII, # File change date and time - 'ImageDescription' => Exif::ASCII, # Image title - 'Make' => Exif::ASCII, # Image input equipment manufacturer - 'Model' => Exif::ASCII, # Image input equipment model - 'Software' => Exif::ASCII, # Software used - 'Artist' => Exif::ASCII, # Person who created the image - 'Copyright' => Exif::ASCII, # Copyright holder + 'DateTime' => self::ASCII, # File change date and time + 'ImageDescription' => self::ASCII, # Image title + 'Make' => self::ASCII, # Image input equipment manufacturer + 'Model' => self::ASCII, # Image input equipment model + 'Software' => self::ASCII, # Software used + 'Artist' => self::ASCII, # Person who created the image + 'Copyright' => self::ASCII, # Copyright holder ], # Exif IFD Attribute Information (p30-31) 'EXIF' => [ # @todo NOTE: Nonexistence of this field is taken to mean nonconformance # to the Exif 2.1 AND 2.2 standards - 'ExifVersion' => Exif::UNDEFINED, # Exif version - 'FlashPixVersion' => Exif::UNDEFINED, # Supported Flashpix version #p32 + 'ExifVersion' => self::UNDEFINED, # Exif version + 'FlashPixVersion' => self::UNDEFINED, # Supported Flashpix version #p32 # Tags relating to Image Data Characteristics - 'ColorSpace' => Exif::SHORT, # Color space information #p32 + 'ColorSpace' => self::SHORT, # Color space information #p32 # Tags relating to image configuration - 'ComponentsConfiguration' => Exif::UNDEFINED, # Meaning of each component #p33 - 'CompressedBitsPerPixel' => Exif::RATIONAL, # Image compression mode - 'PixelYDimension' => Exif::SHORT_OR_LONG, # Valid image height - 'PixelXDimension' => Exif::SHORT_OR_LONG, # Valid image width + 'ComponentsConfiguration' => self::UNDEFINED, # Meaning of each component #p33 + 'CompressedBitsPerPixel' => self::RATIONAL, # Image compression mode + 'PixelYDimension' => self::SHORT_OR_LONG, # Valid image height + 'PixelXDimension' => self::SHORT_OR_LONG, # Valid image width # Tags relating to related user information - 'MakerNote' => Exif::IGNORE, # Manufacturer notes - 'UserComment' => Exif::UNDEFINED, # User comments #p34 + 'MakerNote' => self::IGNORE, # Manufacturer notes + 'UserComment' => self::UNDEFINED, # User comments #p34 # Tags relating to related file information - 'RelatedSoundFile' => Exif::ASCII, # Related audio file + 'RelatedSoundFile' => self::ASCII, # Related audio file # Tags relating to date and time - 'DateTimeOriginal' => Exif::ASCII, # Date and time of original data generation #p36 - 'DateTimeDigitized' => Exif::ASCII, # Date and time of original data generation - 'SubSecTime' => Exif::ASCII, # DateTime subseconds - 'SubSecTimeOriginal' => Exif::ASCII, # DateTimeOriginal subseconds - 'SubSecTimeDigitized' => Exif::ASCII, # DateTimeDigitized subseconds + 'DateTimeOriginal' => self::ASCII, # Date and time of original data generation #p36 + 'DateTimeDigitized' => self::ASCII, # Date and time of original data generation + 'SubSecTime' => self::ASCII, # DateTime subseconds + 'SubSecTimeOriginal' => self::ASCII, # DateTimeOriginal subseconds + 'SubSecTimeDigitized' => self::ASCII, # DateTimeDigitized subseconds # Tags relating to picture-taking conditions (p31) - 'ExposureTime' => Exif::RATIONAL, # Exposure time - 'FNumber' => Exif::RATIONAL, # F Number - 'ExposureProgram' => Exif::SHORT, # Exposure Program #p38 - 'SpectralSensitivity' => Exif::ASCII, # Spectral sensitivity - 'ISOSpeedRatings' => Exif::SHORT, # ISO speed rating - 'OECF' => Exif::IGNORE, + 'ExposureTime' => self::RATIONAL, # Exposure time + 'FNumber' => self::RATIONAL, # F Number + 'ExposureProgram' => self::SHORT, # Exposure Program #p38 + 'SpectralSensitivity' => self::ASCII, # Spectral sensitivity + 'ISOSpeedRatings' => self::SHORT, # ISO speed rating + 'OECF' => self::IGNORE, # Optoelectronic conversion factor. Note: We don't have support for this atm. - 'ShutterSpeedValue' => Exif::SRATIONAL, # Shutter speed - 'ApertureValue' => Exif::RATIONAL, # Aperture - 'BrightnessValue' => Exif::SRATIONAL, # Brightness - 'ExposureBiasValue' => Exif::SRATIONAL, # Exposure bias - 'MaxApertureValue' => Exif::RATIONAL, # Maximum land aperture - 'SubjectDistance' => Exif::RATIONAL, # Subject distance - 'MeteringMode' => Exif::SHORT, # Metering mode #p40 - 'LightSource' => Exif::SHORT, # Light source #p40-41 - 'Flash' => Exif::SHORT, # Flash #p41-42 - 'FocalLength' => Exif::RATIONAL, # Lens focal length - 'SubjectArea' => [ Exif::SHORT, 4 ], # Subject area - 'FlashEnergy' => Exif::RATIONAL, # Flash energy - 'SpatialFrequencyResponse' => Exif::IGNORE, # Spatial frequency response. Not supported atm. - 'FocalPlaneXResolution' => Exif::RATIONAL, # Focal plane X resolution - 'FocalPlaneYResolution' => Exif::RATIONAL, # Focal plane Y resolution - 'FocalPlaneResolutionUnit' => Exif::SHORT, # Focal plane resolution unit #p46 - 'SubjectLocation' => [ Exif::SHORT, 2 ], # Subject location - 'ExposureIndex' => Exif::RATIONAL, # Exposure index - 'SensingMethod' => Exif::SHORT, # Sensing method #p46 - 'FileSource' => Exif::UNDEFINED, # File source #p47 - 'SceneType' => Exif::UNDEFINED, # Scene type #p47 - 'CFAPattern' => Exif::IGNORE, # CFA pattern. not supported atm. - 'CustomRendered' => Exif::SHORT, # Custom image processing #p48 - 'ExposureMode' => Exif::SHORT, # Exposure mode #p48 - 'WhiteBalance' => Exif::SHORT, # White Balance #p49 - 'DigitalZoomRatio' => Exif::RATIONAL, # Digital zoom ration - 'FocalLengthIn35mmFilm' => Exif::SHORT, # Focal length in 35 mm film - 'SceneCaptureType' => Exif::SHORT, # Scene capture type #p49 - 'GainControl' => Exif::SHORT, # Scene control #p49-50 - 'Contrast' => Exif::SHORT, # Contrast #p50 - 'Saturation' => Exif::SHORT, # Saturation #p50 - 'Sharpness' => Exif::SHORT, # Sharpness #p50 - 'DeviceSettingDescription' => Exif::IGNORE, + 'ShutterSpeedValue' => self::SRATIONAL, # Shutter speed + 'ApertureValue' => self::RATIONAL, # Aperture + 'BrightnessValue' => self::SRATIONAL, # Brightness + 'ExposureBiasValue' => self::SRATIONAL, # Exposure bias + 'MaxApertureValue' => self::RATIONAL, # Maximum land aperture + 'SubjectDistance' => self::RATIONAL, # Subject distance + 'MeteringMode' => self::SHORT, # Metering mode #p40 + 'LightSource' => self::SHORT, # Light source #p40-41 + 'Flash' => self::SHORT, # Flash #p41-42 + 'FocalLength' => self::RATIONAL, # Lens focal length + 'SubjectArea' => [ self::SHORT, 4 ], # Subject area + 'FlashEnergy' => self::RATIONAL, # Flash energy + 'SpatialFrequencyResponse' => self::IGNORE, # Spatial frequency response. Not supported atm. + 'FocalPlaneXResolution' => self::RATIONAL, # Focal plane X resolution + 'FocalPlaneYResolution' => self::RATIONAL, # Focal plane Y resolution + 'FocalPlaneResolutionUnit' => self::SHORT, # Focal plane resolution unit #p46 + 'SubjectLocation' => [ self::SHORT, 2 ], # Subject location + 'ExposureIndex' => self::RATIONAL, # Exposure index + 'SensingMethod' => self::SHORT, # Sensing method #p46 + 'FileSource' => self::UNDEFINED, # File source #p47 + 'SceneType' => self::UNDEFINED, # Scene type #p47 + 'CFAPattern' => self::IGNORE, # CFA pattern. not supported atm. + 'CustomRendered' => self::SHORT, # Custom image processing #p48 + 'ExposureMode' => self::SHORT, # Exposure mode #p48 + 'WhiteBalance' => self::SHORT, # White Balance #p49 + 'DigitalZoomRatio' => self::RATIONAL, # Digital zoom ration + 'FocalLengthIn35mmFilm' => self::SHORT, # Focal length in 35 mm film + 'SceneCaptureType' => self::SHORT, # Scene capture type #p49 + 'GainControl' => self::SHORT, # Scene control #p49-50 + 'Contrast' => self::SHORT, # Contrast #p50 + 'Saturation' => self::SHORT, # Saturation #p50 + 'Sharpness' => self::SHORT, # Sharpness #p50 + 'DeviceSettingDescription' => self::IGNORE, # Device settings description. This could maybe be supported. Need to find an # example file that uses this to see if it has stuff of interest in it. - 'SubjectDistanceRange' => Exif::SHORT, # Subject distance range #p51 + 'SubjectDistanceRange' => self::SHORT, # Subject distance range #p51 - 'ImageUniqueID' => Exif::ASCII, # Unique image ID + 'ImageUniqueID' => self::ASCII, # Unique image ID ], # GPS Attribute Information (p52) 'GPS' => [ - 'GPSVersion' => Exif::UNDEFINED, + 'GPSVersion' => self::UNDEFINED, # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix - 'GPSLatitudeRef' => Exif::ASCII, # North or South Latitude #p52-53 - 'GPSLatitude' => [ Exif::RATIONAL, 3 ], # Latitude - 'GPSLongitudeRef' => Exif::ASCII, # East or West Longitude #p53 - 'GPSLongitude' => [ Exif::RATIONAL, 3 ], # Longitude - 'GPSAltitudeRef' => Exif::UNDEFINED, + 'GPSLatitudeRef' => self::ASCII, # North or South Latitude #p52-53 + 'GPSLatitude' => [ self::RATIONAL, 3 ], # Latitude + 'GPSLongitudeRef' => self::ASCII, # East or West Longitude #p53 + 'GPSLongitude' => [ self::RATIONAL, 3 ], # Longitude + 'GPSAltitudeRef' => self::UNDEFINED, # Altitude reference. Note, the exif standard says this should be an EXIF::Byte, # but php seems to disagree. - 'GPSAltitude' => Exif::RATIONAL, # Altitude - 'GPSTimeStamp' => [ Exif::RATIONAL, 3 ], # GPS time (atomic clock) - 'GPSSatellites' => Exif::ASCII, # Satellites used for measurement - 'GPSStatus' => Exif::ASCII, # Receiver status #p54 - 'GPSMeasureMode' => Exif::ASCII, # Measurement mode #p54-55 - 'GPSDOP' => Exif::RATIONAL, # Measurement precision - 'GPSSpeedRef' => Exif::ASCII, # Speed unit #p55 - 'GPSSpeed' => Exif::RATIONAL, # Speed of GPS receiver - 'GPSTrackRef' => Exif::ASCII, # Reference for direction of movement #p55 - 'GPSTrack' => Exif::RATIONAL, # Direction of movement - 'GPSImgDirectionRef' => Exif::ASCII, # Reference for direction of image #p56 - 'GPSImgDirection' => Exif::RATIONAL, # Direction of image - 'GPSMapDatum' => Exif::ASCII, # Geodetic survey data used - 'GPSDestLatitudeRef' => Exif::ASCII, # Reference for latitude of destination #p56 - 'GPSDestLatitude' => [ Exif::RATIONAL, 3 ], # Latitude destination - 'GPSDestLongitudeRef' => Exif::ASCII, # Reference for longitude of destination #p57 - 'GPSDestLongitude' => [ Exif::RATIONAL, 3 ], # Longitude of destination - 'GPSDestBearingRef' => Exif::ASCII, # Reference for bearing of destination #p57 - 'GPSDestBearing' => Exif::RATIONAL, # Bearing of destination - 'GPSDestDistanceRef' => Exif::ASCII, # Reference for distance to destination #p57-58 - 'GPSDestDistance' => Exif::RATIONAL, # Distance to destination - 'GPSProcessingMethod' => Exif::UNDEFINED, # Name of GPS processing method - 'GPSAreaInformation' => Exif::UNDEFINED, # Name of GPS area - 'GPSDateStamp' => Exif::ASCII, # GPS date - 'GPSDifferential' => Exif::SHORT, # GPS differential correction + 'GPSAltitude' => self::RATIONAL, # Altitude + 'GPSTimeStamp' => [ self::RATIONAL, 3 ], # GPS time (atomic clock) + 'GPSSatellites' => self::ASCII, # Satellites used for measurement + 'GPSStatus' => self::ASCII, # Receiver status #p54 + 'GPSMeasureMode' => self::ASCII, # Measurement mode #p54-55 + 'GPSDOP' => self::RATIONAL, # Measurement precision + 'GPSSpeedRef' => self::ASCII, # Speed unit #p55 + 'GPSSpeed' => self::RATIONAL, # Speed of GPS receiver + 'GPSTrackRef' => self::ASCII, # Reference for direction of movement #p55 + 'GPSTrack' => self::RATIONAL, # Direction of movement + 'GPSImgDirectionRef' => self::ASCII, # Reference for direction of image #p56 + 'GPSImgDirection' => self::RATIONAL, # Direction of image + 'GPSMapDatum' => self::ASCII, # Geodetic survey data used + 'GPSDestLatitudeRef' => self::ASCII, # Reference for latitude of destination #p56 + 'GPSDestLatitude' => [ self::RATIONAL, 3 ], # Latitude destination + 'GPSDestLongitudeRef' => self::ASCII, # Reference for longitude of destination #p57 + 'GPSDestLongitude' => [ self::RATIONAL, 3 ], # Longitude of destination + 'GPSDestBearingRef' => self::ASCII, # Reference for bearing of destination #p57 + 'GPSDestBearing' => self::RATIONAL, # Bearing of destination + 'GPSDestDistanceRef' => self::ASCII, # Reference for distance to destination #p57-58 + 'GPSDestDistance' => self::RATIONAL, # Distance to destination + 'GPSProcessingMethod' => self::UNDEFINED, # Name of GPS processing method + 'GPSAreaInformation' => self::UNDEFINED, # Name of GPS area + 'GPSDateStamp' => self::ASCII, # GPS date + 'GPSDifferential' => self::SHORT, # GPS differential correction ], ]; @@ -362,7 +360,6 @@ class Exif { * if we make up our own types like Exif::DATE. */ function collapseData() { - $this->exifGPStoNumber( 'GPSLatitude' ); $this->exifGPStoNumber( 'GPSDestLatitude' ); $this->exifGPStoNumber( 'GPSLongitude' ); @@ -446,7 +443,6 @@ class Exif { */ private function charCodeString( $prop ) { if ( isset( $this->mFilteredExifData[$prop] ) ) { - if ( strlen( $this->mFilteredExifData[$prop] ) <= 8 ) { // invalid. Must be at least 9 bytes long. @@ -763,43 +759,43 @@ class Exif { } // Does not work if not typecast switch ( (string)$etype ) { - case (string)Exif::BYTE: + case (string)self::BYTE: $this->debug( $val, __FUNCTION__, $debug ); return $this->isByte( $val ); - case (string)Exif::ASCII: + case (string)self::ASCII: $this->debug( $val, __FUNCTION__, $debug ); return $this->isASCII( $val ); - case (string)Exif::SHORT: + case (string)self::SHORT: $this->debug( $val, __FUNCTION__, $debug ); return $this->isShort( $val ); - case (string)Exif::LONG: + case (string)self::LONG: $this->debug( $val, __FUNCTION__, $debug ); return $this->isLong( $val ); - case (string)Exif::RATIONAL: + case (string)self::RATIONAL: $this->debug( $val, __FUNCTION__, $debug ); return $this->isRational( $val ); - case (string)Exif::SHORT_OR_LONG: + case (string)self::SHORT_OR_LONG: $this->debug( $val, __FUNCTION__, $debug ); return $this->isShort( $val ) || $this->isLong( $val ); - case (string)Exif::UNDEFINED: + case (string)self::UNDEFINED: $this->debug( $val, __FUNCTION__, $debug ); return $this->isUndefined( $val ); - case (string)Exif::SLONG: + case (string)self::SLONG: $this->debug( $val, __FUNCTION__, $debug ); return $this->isSlong( $val ); - case (string)Exif::SRATIONAL: + case (string)self::SRATIONAL: $this->debug( $val, __FUNCTION__, $debug ); return $this->isSrational( $val ); - case (string)Exif::IGNORE: + case (string)self::IGNORE: $this->debug( $val, __FUNCTION__, $debug ); return false;