[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

How to validate the image dimension of certain range?

I have a preset image variable $maxwidth and $maxheight of 110 and 176 pixels.

I managed to obtain the image dimension in the variable of $width and $height.

176 / 110 is equal to 1.6

I would like to validate an image using a variable $acceptable so that $height / $width is within the range of 1.58 ~ 1.62.

$acceptable will be equal to 1 if the image aspect ratio is within 1.58 ~ 1.62, or else 0 will be assigned.

I need this short piece of coding for validation.
0
jay28lee
Asked:
jay28lee
2 Solutions
 
enachemcCommented:
$acceptable = 0;
if($height / $width >= 1.58 && $height / $width <= 1.62)$acceptable=1;
0
 
ozoCommented:
$acceptable = 0+($width*1.58<=$height && $height <= $width*1.62);
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now