nativegallery-weryskok/app/Services/EXIF.php

31 lines
634 B
PHP
Raw Permalink Normal View History

2024-07-05 07:26:39 +03:00
<?php
namespace App\Services;
class EXIF
{
2024-07-05 09:49:49 +03:00
private $data;
2024-07-05 07:26:39 +03:00
public function __construct($file)
{
$exif = exif_read_data($file, 0, true);
$jsonData = [];
2024-07-05 09:49:49 +03:00
2024-07-05 07:26:39 +03:00
if ($exif !== false) {
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
$jsonData["$key.$name"] = $val;
}
}
2024-07-05 09:49:49 +03:00
$this->data = json_encode($jsonData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
} else {
$this->data = null;
2024-07-05 07:26:39 +03:00
}
2024-07-05 09:49:49 +03:00
}
public function getData()
{
return $this->data;
2024-07-05 07:26:39 +03:00
}
}