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

[4.x]: Division by zero #13712

Closed
kringkaste opened this issue Sep 18, 2023 · 3 comments
Closed

[4.x]: Division by zero #13712

kringkaste opened this issue Sep 18, 2023 · 3 comments
Assignees

Comments

@kringkaste
Copy link
Contributor

What happened?

Description

If you have an image with a very small and a very large side at the same time (like 1x200px), the Image::calculateMissingDimension() creates a targetWidth of 0 and then the Raster::scaleAndCrop() generates a Division by Zero on line 330 (Craft 4.4.17). The round() function in Image::calculateMissingDimension() produces a 0 and it should always return a minimum of 1.

Steps to reproduce

  1. Upload an image of 1x200px or something like that to a folder and the thumbnail generation produces the error.

Expected behavior

A thumbnail of the image or a fall back image.

Actual behavior

Division by zero.

Craft CMS version

4.4.17

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@i-just
Copy link
Contributor

i-just commented Sep 20, 2023

Hi, thanks for reporting! I raised a PR to adjust this.

@brandonkelly
Copy link
Member

Fixed for the next release via #13719.

@brandonkelly
Copy link
Member

Craft 4.5.6 is out now with that fix.

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

3 participants