Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JoshMountain's avatar

Image dimension validation failing for ratio 1/1

For some reason my image dimension validation is failing when I have ratio=1 trying to validate square images only.

$this->validate($request, [
    'image' => 'required|image|dimensions:min_width=1400,min_height=1400,max_width=3000,max_height=3000,ratio=1/1',
]);

The image I am using to test is: http://i.imgur.com/wtZCXWM.png it is 1400x1400

When I remove ratio=1 the validation passes. I also tried ratio=1.0 and ratio=1/1 but no luck.

0 likes
4 replies
ralphmrivera's avatar

FYI, what worked for me was ratio=0/0 - presumably because there is no variation between width and height.

JoshMountain's avatar

I haven't found a solution. Does 0/0 actually check to square images?

ralphmrivera's avatar

0/0 worked for me. But I'm not crazy about not knowing why.

Please or to participate in this conversation.