Scan image EXIF infos

@return array An array of retrieved image's infos
328706
public function getExifInfos()
    {
        if (!$this->exists()) {
            return false;
        }
        $exifdata = array();
        if ($data = exif_read_data($this->getRealPath(), 'EXIF', true)) {
            foreach ($data as $key => $section) {
                foreach ($section as $name => $value) {
                    if (is_string($value)) {
                        if (!isset($exifdata[$name])) {
                            $exifdata[$name] = '';
                        }
                        $exifdata[$name] .= $value;
                    } elseif (is_array($value)) {
                        if (!isset($exifdata[$name])) {
                            $exifdata[$name] = array();
                        }
                        $exifdata[$name][] = $value;
                    }
                }
            }
            if (!empty($exifdata["GPSLongitude"]) && !empty($exifdata['GPSLongitudeRef'])) {
                $exifdata["GPSLongitudeTransformed"] = self::getGps($exifdata["GPSLongitude"][0], $exifdata['GPSLongitudeRef'][0]);
            }
            if (!empty($exifdata["GPSLatitude"]) && !empty($exifdata['GPSLatitudeRef'])) {
                $exifdata["GPSLatitudeTransformed"] = self::getGps($exifdata["GPSLatitude"][0], $exifdata['GPSLatitudeRef'][0]);
            }
            if (!empty($exifdata["DateTime"])) {
                $exifdata["DateTimeTransformed"] = self::getDateFromExif($exifdata["DateTime"]);
            }
            if (!empty($exifdata["DateTimeOriginal"])) {
                $exifdata["DateTimeOriginalTransformed"] = self::getDateFromExif($exifdata["DateTimeOriginal"]);
            }
        }
        return $exifdata;
    }
1315746
protected function getListImageStyle()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            $list = $this->image_style->getList();
            $this->limitArray($list);
            return $list;
        }

        if (!is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $result = $this->image_style->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
268589
public function toArray()
    {
        return [
            'filename' => $this->filename,
            'original_filename' => $this->original_filename,
            'title' => $this->title,
            'alt' => $this->alt,
            'description' => '',
            'size' => $this->size,
            'extension' => $this->extension
        ];
    }
251077
protected function getClassesToScan()
		{
			$classes = [];

			foreach ($this->scan as $class) {
				try {
					$classes[] = new ReflectionClass($class);
				} catch (\Exception $e) {
					//
				}
			}

			return $classes;
		}
243909
public function getScanPaths()
    {
        $paths = $this->paths;

        $paths[] = $this->getPath().'/*';

        if ($this->config('scan.enabled')) {
            $paths = array_merge($paths, $this->config('scan.paths'));
        }

        return $paths;
    }
1158299
function processImage()
    {
        if ( $this->StoredFile == '' )
            return true;
        $fileArray = array( $this->StoredPath, $this->StoredFile );
        $filePath = eZDir::path( $fileArray );
        $imageinfo = getimagesize( $filePath );
        if ( $imageinfo )
        {
            $width = $imageinfo[0];
            $height = $imageinfo[1];
            if ( $this->load() )
            {
                $this->Width = $width;
                $this->Height = $height;
                return true;
            }
            else
                eZDebug::writeWarning( "Image failed to load '$filePath'", __METHOD__ );
        }
        else
            eZDebug::writeWarning( "No image info could be extracted from '$filePath'", __METHOD__ );
        return false;
    }
1327460
private function getFiles(): array
	{
		$result = [];
		$files = Finder::find('*')
			->in($this->getFullPath());
		foreach ($files as $file) {
			$result[] = new FileInfo($file);
		}
		usort($result, function ($a, $b) {
			if ($a->isDir == $b->isDir) {
				return strcmp($a->name, $b->name);
			} else {
				if ($a->isDir) {
					return -1;
				} else {
					return 1;
				}
			}
		});
		return $result;
	}
504554
public function getImageAlignOptions()
    {
        return [
            self::IMAGE_ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'),
            self::IMAGE_ALIGN_RIGHT => _t(__CLASS__ . '.LEFT', 'Right'),
            self::IMAGE_ALIGN_STAGGER => _t(__CLASS__ . '.LEFT', 'Stagger')
        ];
    }
1044192
public function getDimensions()
    {
        $imageDimension = getimagesize($this->image);

        $width  = $imageDimension[0];
        $height = $imageDimension[1];

        foreach($this->effect as $effect)
        {
            if($effect instanceof PictureEffect)
            {
                $modified = $effect->getNewDimensions($width, $height);

                $width  = $modified['w'];
                $height = $modified['h'];
            }
        }

        return array(

            'w' => $width,
            'h' => $height,
        );
    }
248877
public function getInfo() : array
    {
        if ($this->processed === true) {
            return [
                'canvas' => [
                    'width' => $this->canvas['width'],
                    'height' => $this->canvas['height'],
                    'color' => $this->canvas['color']
                ],
                'resized-image' => [
                    'width' => $this->intermediate['width'],
                    'height' => $this->intermediate['height']
                ],
                'canvas-placement' => [
                    'x' => $this->canvas['spacing']['x'],
                    'y' => $this->canvas['spacing']['y']
                ],
                'resizer' => [
                    'maintain-aspect-ratio' => $this->intermediate['maintain_aspect'],
                    'quality' => $this->canvas['quality']
                ]
            ];
        } else {
            throw new \Exception(Helper::ERROR_CALL_GETINFO);
        }
    }
1276966
public function data() : array
    {
        $data = array();

        $data['classes'] = implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-index'), $this->post_type, $this->args));

        // Get column classes
        $data['columnClass'] = 'grid-md-6';
        if (!empty(get_field('index_columns', $this->ID))) {
            $data['columnClass'] = get_field('index_columns', $this->ID);
        }

        $data['imageDimension'] = $this->getImageDimension($data['columnClass']);

        // Get the index items
        $data['items'] = $this->prepareItems(get_field('index', $this->ID));

        return $data;
    }
380146
public function getData(array $image_extensions = ['gif'], array $skip = ['unknown.gif', 'recycle.bin.empty.gif', 'recycle.bin.full.gif']): array
    {
        // Cached
        if (isset(self::$data[$this->directory_with_icons])) {
            $data = self::$data[$this->directory_with_icons];
        } else {
            // Scan folder
            $data = [];
            $image_extensions = array_flip($image_extensions);

            foreach (array_diff(scandir(DIR_BASE . $this->directory_with_icons, SCANDIR_SORT_NONE),['.', '..']) as $file) {
                $extension = explode('.', $file);

                if (!isset($image_extensions[array_pop($extension)])) {
                    continue;
                }

                foreach ($extension as $v) {
                    $data[$v] = $file;
                }
            }

            // Save in cache
            self::$data[$this->directory_with_icons] = $data;
        }

        return $skip ? array_diff($data, $skip) : $data;
    }
595010
public static function photos()
    {
        if (!getConfig('sitemap.photos')) {
            return [];
        }

        $table = TableRegistry::get('MeCms.PhotosAlbums');
        $url = Cache::read('sitemap', $table->getCacheName());

        if (!$url) {
            $alias = $table->Photos->getAlias();

            $albums = $table->find('active')
                ->select(['id', 'slug'])
                ->contain($alias, function (Query $q) use ($alias) {
                    return $q->find('active')
                        ->select(['id', 'album_id', 'modified'])
                        ->order([sprintf('%s.modified', $alias) => 'DESC']);
                });

            if ($albums->isEmpty()) {
                return [];
            }

            $latest = $table->Photos->find('active')
                ->select(['modified'])
                ->order([sprintf('%s.modified', $alias) => 'DESC'])
                ->firstOrFail();

            //Adds albums index
            $url[] = self::parse(['_name' => 'albums'], ['lastmod' => $latest->modified]);

            foreach ($albums as $album) {
                //Adds the album
                $url[] = self::parse(['_name' => 'album', $album->slug], ['lastmod' => array_value_first($album->photos)->modified]);

                //Adds each photo
                foreach ($album->photos as $photo) {
                    $url[] = self::parse(
                        ['_name' => 'photo', 'slug' => $album->slug, 'id' => $photo->id],
                        ['lastmod' => $photo->modified]
                    );
                }
            }

            Cache::write('sitemap', $url, $table->getCacheName());
        }

        return $url;
    }
1009077
public function actionImagesInfo()
    {
        $ids = Yii::$app->request->getBodyParam('ids', []);
        $ids = array_unique($ids);
        return new ActiveDataProvider([
            'query' => StorageImage::find()->where(['in', 'id', $ids])->with(['file', 'tinyCropImage.file']),
            'pagination' => false,
        ]);
    }
42266
protected function forPictures() : array
    {
        $pictures = Collection::make($this->all())->filter(function($item, $key) {
            return $key == 'pictures';
        })->get('pictures');

        if (is_null($pictures) || empty($pictures['storing'])) {
            return [];
        }

        return Collection::make($pictures['storing'])->mapWithKeys(function($item, $key) {
            return ['pictures.storing.' . $key => [
                'mimes:jpeg,png,jpg',
                Rule::dimensions()->maxWidth(1000)->maxHeight(500)
            ]];
        })->all();
    }
338961
public function attributes(): array
    {
        $attributes = [];

        if (!$this->isExternal() || $this->fileExists()) {
            $file = $this->folder() . $this->multimedia_file_refn;

            $attributes['__FILE_SIZE__'] = $this->fileSizeKB();

            $imgsize = getimagesize($file);
            if (is_array($imgsize) && !empty($imgsize['0'])) {
                $attributes['__IMAGE_SIZE__'] = I18N::translate('%1$s × %2$s pixels', I18N::number($imgsize['0']), I18N::number($imgsize['1']));
            }
        }

        return $attributes;
    }
1103119
public function getThumbnail() {
    $media = $this->getMedia();

    // We loop through all the media items and return the first image.
    foreach ($media as $media_item) {
      if (isset($media_item['media_type']) && $media_item['media_type'] == 'image') {
        return $media_item;
      }
    }

    return [];
  }