Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Conversions crashes when generating previews of PDF file #3465

Closed
kduma opened this issue Dec 19, 2023 · 2 comments
Closed

[11.x] Conversions crashes when generating previews of PDF file #3465

kduma opened this issue Dec 19, 2023 · 2 comments

Comments

@kduma
Copy link
Contributor

kduma commented Dec 19, 2023

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

@kduma kduma changed the title [11.x] Conversions fail when generating previews of PDF file [11.x] Conversions crashes when generating previews of PDF file Dec 19, 2023
@freekmurze
Copy link
Member

This has been fixed in the latest version of the package.

@kduma
Copy link
Contributor Author

kduma commented Dec 22, 2023

This has been fixed in the latest version of the package.

@freekmurze Unfortunately, not exactly - see #3475

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants