2

在 Laravel 8 应用程序中使用spatie/laravel-medialibrary8 我想知道是否有办法获取上传图像的尺寸(宽度*高度)?

提前致谢!

4

1 回答 1

1

我没有测试过代码。

Spatie MediaLibrary在后台使用 spatie Image包来生成响应式图像。

由于图像包具有获取图像属性的选项

所以你可以做这样的事情。

$fullPathToImage = 'your-path-here';

$imageInstance = Spatie\MediaLibrary\Support\ImageFactory::load($fullPathToImage);


$imageWidth = $imageInstance->getWidth();
$imageHeight = $imageInstance->getHeight();

因为我没有测试过代码。但它将为您提供解决问题的某种起点。

于 2021-12-13T08:27:44.103 回答