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

Cover resizing is incorrect #1359

Closed
btamas86 opened this issue Jun 6, 2024 · 3 comments
Closed

Cover resizing is incorrect #1359

btamas86 opened this issue Jun 6, 2024 · 3 comments
Assignees

Comments

@btamas86
Copy link

btamas86 commented Jun 6, 2024

Describe the bug
I use the "cover" type of resizing and I noticed that if the original image is odd in size, the resizing is incorrect.

Original image size: 375x250
Requested size: 240x90
Received size: 239x90

So it is rounded down, not up, which I think is a problem.

Code Example

$imageContent = file_get_contents('image.jpg');
$image = (new Intervention\Image\ImageManager(new Intervention\Image\Drivers\Gd\Driver))->read($imageContent);
$image->cover(240, 90, 'center');
$imgEncoded = $image->encodeByMediaType(quality: 85);

response((string)$imgEncoded)
    ->withHeaders([
        'Content-type' => $imgEncoded->mediaType(),
    ]);

Images
Original:
4k-wallpaper-background-beautiful-853199-horizontal
Resized:
image

Environment (please complete the following information):

  • PHP Version: 8.2.17 (php:8.2.17-apache)
  • OS: Debian GNU/Linux 12 (bookworm), 6.6.26-linuxkit
  • Intervention Image Version: 3.6.4
  • GD or Imagick: GD
@olivervogel
Copy link
Member

Thanks for reporting. Yes, I can confirm the bug. Unfortunately it happens with GD and Imagick. I will look into it.

@btamas86
Copy link
Author

btamas86 commented Jun 6, 2024

Thank you very much!

@olivervogel
Copy link
Member

This is now fixed in 3.6.5.

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

No branches or pull requests

2 participants