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] Incorrect PDF conversion results when used with GD driver #3475

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

[11.x] Incorrect PDF conversion results when used with GD driver #3475

kduma opened this issue Dec 22, 2023 · 2 comments

Comments

@kduma
Copy link
Contributor

kduma commented Dec 22, 2023

Continuation of #3465.

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

Given the following test case: ExampleTest.php

$user = \App\Models\User::factory()
    ->create();

$user
    ->addMedia(resource_path('dummy.pdf'))
    ->preservingOriginal()
    ->toMediaCollection();

$path = $user->getFirstMediaPath(conversionName: 'preview');

[$width, $height] = getimagesize($path);

$this->assertEquals(300, $width, 'The width of the conversion is not 300px.');
$this->assertEquals(300, $height, 'The height of the conversion is not 300px.');

The generated conversion is incorrect. Here are results from failed assertions:

1) The width of the conversion is not 300px.
Failed asserting that 1190 matches expected 300.
Expected :300
Actual   :1190

2) The height of the conversion is not 300px.
Failed asserting that 1684 matches expected 300.
Expected :300
Actual   :1684

Repository with test app: kduma-archive/test-laravel-medialibrary-failing-pdf

@kduma kduma changed the title [11.x] Incorrect conversion results when used with GD driver [11.x] Incorrect PDF conversion results when used with GD driver Dec 22, 2023
@freekmurze
Copy link
Member

Let me know when #3476 can be reviewed.

Thanks for you work on this.

@kduma
Copy link
Contributor Author

kduma commented Dec 22, 2023

Let me know when #3476 can be reviewed.

Thanks for you work on this.

@freekmurze Looks that spatie/image#221 PR fixes this.

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