Sorry, there is an error on input

Enter a (numeric only) value in both width and height fields.

'; return false; } return true; } public function doCalculate ($w_or_h,$teller,$w,$h) { //this is the actual calculation of the resulting values, and the embedding in the html code for a line if($w_or_h=="w"){ $result='

width="'.$teller.'" height="'.round($h/($w/$teller)).'"'; $mid= substr(strval($h/($w/$teller)),-2)=='.5'?'~':''; } else{ $result='

width="'.round($w/($h/$teller)).'" height="'.$teller.'"'; $mid= substr(strval($w/($h/$teller)),-2)=='.5'?'~':''; } // with $mid we catch if the value is exact between two integers (.5). The only means is to add a value (~) to $mid // May be omitted, it's not of great importance return $result.'   '.$mid.'

'; } } ?>

Proportional image width height calculator

Enter the orginal width and height of an image.
You will see the proportional values of width and height for the purpose of scaling down the image.
You can copy and paste the width and height values into the <img> tag of your html code.
When you see ~, the calculated width or height value is exactly in the middle between two integers, (e.g. 30.5) and is then rounded up (e.g. 31).

Original width: Original height:



Showing steps of '.$step.'px (Click Calculate to change the steprate)
'; //We make an object of the Calculate class: $obj=new Calculate; // Some basic input check, checking if there is a value, and whether the value is numeric. // The input field maxlength limits the value to 9999, but you may want to extend this input check // so that it limits to the maximum value of your choice. if ($obj->validateInput()){ echo '

Scaling from '.($_POST['w_or_h']=="w"?"width":"height").' (calculating '.($_POST['w_or_h']=="w"?"height":"width").')

'; for($i=1;$i<=($_POST['w_or_h']=="w"?$_POST['orwidth']:$_POST['orheight']);$i++){ if(!$_POST['stepswitch'] || !($i%10)){ //reference to the doCalculate function in the Calculate class echo $obj->doCalculate($_POST['w_or_h'],$i,$_POST['orwidth'],$_POST['orheight']); $counter++; } if(!($counter%30)){ //every 30 items option to go top of page echo'

top of page

'; $counter=1; } } // end for } // end if } // end post ?>