I am trying to get the image exif data so that I can use the Image intervention orientate function.
The only problem is that I cant read the exif data using the Storage::get()
First I am storing Uploaded images like this:
$filename = uniqid().'.'.$file->getClientOriginalExtension();
$path = "images/$id/$filename";
Storage::put($path, File::get($file->getRealPath()));
The in a queue I am reading the images, doing some resizing and upload to AWS:
$image = Image::make(Storage::disk('images')->get("$this->id/$file"));
$image->orientate();
$image->resize(null, 600, function ($constraint) {
$constraint->aspectRatio();
});
$image->stream('jpg', 85);
Storage::put("images/$this->id/main/$file", $image);
$image->destroy();
The image does get resized and uploaded to AWS but the only problem is that it will show up sideways, so it seems that I cant read the exif data using:
Storage::disk('images')->get("$this->id/$file")
I have runned: php -m | more and I can see that "exif" is listed so I have the module in my Laravel Forge DO server
Install Intervention\Image
by following command.
composer require intervention/image
Update config/app.php
'providers' => [
Intervention\Image\ImageServiceProvider::class
],
'aliases' => [
'Image' => Intervention\Image\Facades\Image::class
]
Use Library:
$data = Image::make(public_path('IMG.jpg'))->exif();
if (isset($data['GPSLatitude'])) {
$lat = eval('return ' . $data['GPSLatitude'][0] . ';')
+ (eval('return ' . $data['GPSLatitude'][1] . ';') / 60)
+ (eval('return ' . $data['GPSLatitude'][2] . ';') / 3600);
$lng = eval('return ' . $data['GPSLongitude'][0] . ';')
+ (eval('return ' . $data['GPSLongitude'][1] . ';') / 60)
+ (eval('return ' . $data['GPSLongitude'][2] . ';') / 3600);
echo "$lat, $lng";
} else {
echo "No GPS Info";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With