mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-20 00:42:16 +00:00
get exif data refactoring
This commit is contained in:
@@ -723,19 +723,6 @@ if (! function_exists('map_language_translations')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_file_type_from_mimetype')) {
|
||||
/**
|
||||
* Get file type from mimetype
|
||||
*
|
||||
* @param $mimetype
|
||||
* @return mixed
|
||||
*/
|
||||
function get_file_type_from_mimetype($mimetype)
|
||||
{
|
||||
return explode('/', $mimetype)[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('getPrettyName')) {
|
||||
/**
|
||||
* Format pretty name file
|
||||
@@ -756,40 +743,6 @@ if (! function_exists('getPrettyName')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('readExifData')) {
|
||||
/**
|
||||
* Get exif data from jpeg image
|
||||
*/
|
||||
function readExifData(string $file): object|null
|
||||
{
|
||||
$mimetype = Storage::mimeType($file);
|
||||
|
||||
if (!$mimetype) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$type = get_file_type_from_mimetype(
|
||||
Storage::mimeType($file)
|
||||
);
|
||||
|
||||
if ($type !== 'jpeg') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// Try to get the exif data
|
||||
$data = Image::make(Storage::path($file))->exif();
|
||||
|
||||
// Encode data
|
||||
$encodedData = mb_convert_encoding($data, 'UTF8', 'UTF8');
|
||||
|
||||
return json_decode(json_encode($encodedData));
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_default_language_translations')) {
|
||||
/**
|
||||
* @return Collection
|
||||
|
||||
Reference in New Issue
Block a user