Imbo\EventListener\ExifMetadata::parseProperties PHP Method

parseProperties() protected method

Parse an array of properties into a storable format
protected parseProperties ( array $rawProperties ) : array
$rawProperties array An array of properties to parse
return array Parsed array of properties
    protected function parseProperties(array $rawProperties)
    {
        if (isset($rawProperties['exif:GPSLatitude']) && isset($rawProperties['exif:GPSLongitude'])) {
            // We store coordinates in GeoJSON-format (lng/lat)
            $rawProperties['gps:location'] = [$this->parseGpsCoordinate($rawProperties['exif:GPSLongitude'], $rawProperties['exif:GPSLongitudeRef']), $this->parseGpsCoordinate($rawProperties['exif:GPSLatitude'], $rawProperties['exif:GPSLatitudeRef'])];
        }
        if (isset($rawProperties['exif:GPSAltitude'])) {
            $alt = explode('/', $rawProperties['exif:GPSAltitude'], 2);
            $rawProperties['gps:altitude'] = $alt[0] / (int) $alt[1];
        }
        $properties = [];
        foreach ($rawProperties as $key => $val) {
            // Get rid of dots in property names
            $key = str_replace('.', ':', $key);
            // Replace underscore with dash for png properties
            if (substr($key, 0, 3) === 'png') {
                $key = str_replace('_', '-', $key);
            }
            $properties[$key] = $val;
        }
        return $properties;
    }