I have this code snippet which annoyingly doesn't work.
It did until I inserted the bits in red.
I have been using it for years but now need to add the conditional.
Main question is why it fails to work but also, why is $size (in blue) not an array. It works as a scalar but contains 2 pieces of data.
Is there a format of construct like the Perl 'if(($x > 3) or ($x < 40)){' in PHP? The manuals just refer to if and else then move on to something else
Keith
It did until I inserted the bits in red.
I have been using it for years but now need to add the conditional.
Main question is why it fails to work but also, why is $size (in blue) not an array. It works as a scalar but contains 2 pieces of data.
Is there a format of construct like the Perl 'if(($x > 3) or ($x < 40)){' in PHP? The manuals just refer to if and else then move on to something else
Code:
[blue]$size[/blue]=GetImageSize($img_name);
[red] $flag=0;
if($size[0] > $MAXIMUM_WIDTH){
$flag=1;
}
if($size[1] > $MAXIMUM_HEIGHT){
$flag=1;
}
if($flag > 1){
[/red]
$width_ratio = (double) ($size[0] / $max_width);
$height_ratio = (double) ($size[1] / $max_height);
if($width_ratio >=$height_ratio)
{
$ratio = $width_ratio;
}
else
{
$ratio = $height_ratio;
}
$new_width = ($size[0] / $ratio);
$new_height = ($size[1] / $ratio);
[red] }else{
$new_width = $size[0];
$new_height = ($size[1];
}
[/red]
Keith