spatie/laravel-medialibrary 如何获取上传图片的尺寸?
How in spatie/laravel-medialibrary get dimensions of uploaded image?
在 Laravel 8 应用程序中使用 spatie/laravel-medialibrary
8 我想知道是否有办法获取尺寸(宽度*高度)
上传图片的数量?
提前致谢!
我还没有测试代码。
Spatie MediaLibrary uses spatie Image 在幕后打包以生成响应图像。
自从 image package has a option to get the Image Properties
所以你可以做这样的事情。
$fullPathToImage = 'your-path-here';
$imageInstance = Spatie\MediaLibrary\Support\ImageFactory::load($fullPathToImage);
$imageWidth = $imageInstance->getWidth();
$imageHeight = $imageInstance->getHeight();
因为我还没有测试代码。但它将为您提供某种解决问题的起点。
在 Laravel 8 应用程序中使用 spatie/laravel-medialibrary
8 我想知道是否有办法获取尺寸(宽度*高度)
上传图片的数量?
提前致谢!
我还没有测试代码。
Spatie MediaLibrary uses spatie Image 在幕后打包以生成响应图像。
自从 image package has a option to get the Image Properties
所以你可以做这样的事情。
$fullPathToImage = 'your-path-here';
$imageInstance = Spatie\MediaLibrary\Support\ImageFactory::load($fullPathToImage);
$imageWidth = $imageInstance->getWidth();
$imageHeight = $imageInstance->getHeight();
因为我还没有测试代码。但它将为您提供某种解决问题的起点。