-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.4] Ratio validation - allow precision to be based on size of image #19542
Conversation
I don't get this line: $precision = $maxDimension / $maxDimension ** 2; Isn't that equivalent to: $precision = 1 / $maxDimension; |
@charliekassel why don't we just change the 0.000001? |
@KKSzymanowski - it is indeed sir. Your math is better than mine. |
@charliekassel can you please share a real world example of the problem? What image size and what ration fails? |
Expanding on the examples above.
So you see for a 2/3 ratio image we need go up to 1 million pixels in width in order to pass current precision rules. That's a pretty big image. Using a precision based on the size of the maximum dimension for above sizes we would get:
|
I have added a fixture and a test to assert this works. |
@charliekassel I see now, thanks. I think this is ok |
The precision required to pass ratio validation is quite strict.
Images must have full pixels dimensions when cropping or resizing an image to a specific ratio, decimals must be rounded either up or down to the nearest pixel. This creates an inaccuracy of the required ratio and the inaccuracy is amplified the smaller the image is.
This PR changes the precision required based on the size of the image.
Precision based on max pixel dimension of image
Example inaccuracy of ratio based on above image sizes
So this change allows these proportions to pass the validation, whereas they would all have failed given a 0.000001 precision factor.