예제 #1
0
 /**
  * Process File and retrieve Latitude and Longitude from image EXIF data
  *
  * @param Image $image
  * @param File $file
  * @return Image
  */
 public function processExifData(Image $image, File $file)
 {
     try {
         /**
          * Read EXIF data from image file
          */
         $exif = exif_read_data($file, 0, true);
         /**
          * Check if file has GPS data
          */
         $gps = $exif['GPS'];
         $exifData = new ExifData();
         $exifData->setLatitude($this->getGps($gps['GPSLatitude'], $gps['GPSLatitudeRef']));
         $exifData->setLongitude($this->getGps($gps['GPSLongitude'], $gps['GPSLongitudeRef']));
         $image->setExifData($exifData);
     } catch (\Exception $exception) {
         if ('Symfony\\Component\\Debug\\Exception\\ContextErrorException' == get_class($exception)) {
             $this->addError('Currently you can only upload images with GPS data. For more info visit our Help page.');
         } else {
             $this->addError($exception->getMessage());
         }
     }
     return $image;
 }
예제 #2
0
 public function getOriginal(Image $image)
 {
     $filePath = sprintf('gaufrette://uploads/%s', $image->getPreviewPath());
     /* If file already exists deliver it */
     if (file_exists($filePath)) {
         return file_get_contents($filePath);
     }
 }