Laravel Storage :: get()不返回图像的exif数据 [英] Laravel Storage::get() does not return exif data of image

查看:769
本文介绍了Laravel Storage :: get()不返回图像的exif数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取图像exif数据,以便我可以使用图像干预定向功能。

I am trying to get the image exif data so that I can use the Image intervention orientate function.

唯一的问题是我无法使用exif数据读取存储:: get()

The only problem is that I cant read the exif data using the Storage::get()

首先我存储像这样的Uploaded图像:

First I am storing Uploaded images like this:

$filename = uniqid().'.'.$file->getClientOriginalExtension();
$path = "images/$id/$filename";
Storage::put($path, File::get($file->getRealPath()));

在队列中我正在阅读图片,做一些调整大小并上传到AWS:

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();

图像确实调整大小并上传到AWS,但唯一的问题是它会显示在侧面,所以我似乎无法使用以下方法读取exif数据:

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")

我跑过:php -m |更多,我可以看到列出exif所以我在Laravel Forge DO服务器中有模块

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

推荐答案

安装干预\图像按照以下命令。

作曲家需要介入/图像

更新 config / app.php

'providers'=> [
Intervention\Image\ImageServiceProvider :: class
],
'aliases'=> [
'Image'=> Intervention\Image\Facades \图像:: class
]

使用库:

$ 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;
}其他{
echo没有GPS信息;
}

这篇关于Laravel Storage :: get()不返回图像的exif数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆