Closed kduma closed 11 months ago
Given following test case: ExampleTest.php
$user = \App\Models\User::factory() ->create(); $user ->addMedia(resource_path('dummy.pdf')) ->preservingOriginal() ->toMediaCollection();
With following configuration in User.php model:
public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('preview') ->fit(Fit::Crop, 300, 300) ->format('png') ->nonQueued(); }
There is a crash:
Spatie\Image\Exceptions\UnsupportedImageFormat: Unsupported format `pdf`. /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/vendor/spatie/image/src/Exceptions/UnsupportedImageFormat.php:11 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/vendor/spatie/image/src/Drivers/Gd/GdDriver.php:153 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/vendor/spatie/image/src/Image.php:85 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/Conversions/Actions/PerformManipulationsAction.php:38 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/Conversions/Actions/PerformConversionAction.php:30 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/Conversions/FileManipulator.php:71 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php:240 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/Conversions/FileManipulator.php:70 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/Conversions/FileManipulator.php:39 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/MediaCollections/Filesystem.php:37 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/MediaCollections/FileAdder.php:438 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/MediaCollections/FileAdder.php:420 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/package-sources-laravel-medialibrary/src/MediaCollections/FileAdder.php:339 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/tests/Feature/ExampleTest.php:23 /Users/kduma/Developer/web/test-laravel-medialibrary-failing-pdf/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:176
Repository with test app: kduma-archive/test-laravel-medialibrary-failing-pdf
This has been fixed in the latest version of the package.
@freekmurze Unfortunately, not exactly - see #3475
Given following test case: ExampleTest.php
With following configuration in User.php model:
There is a crash:
Repository with test app: kduma-archive/test-laravel-medialibrary-failing-pdf