Resizing image without changing Aspect Ratio

resize

I had written a piece of code like this. I’ve copied it below, use that code for your project..& gave your suggestion?

 

 

 

 

1) HTML => Code for file upload:
<form action=”upload.php”>

<input type=”file” name=”uploadFile” />

<input type=”submit” />

</form>

2) For DB image use below code to get a file

<?php

$file=”../images/logo1.jpg”;

list($width,$height)=getfilesize($file);

?>

3) PHP => Code for get and resize image:

Filename : upload.php

<?php

$file=$_FILES[‘uploadFile’];

list($width,$height)=getfilesize($file);

$target_size=400;

$percent=$target_size/$width;  or  $percent=$target_size/$height;

$new_width=$width*$percent;

$new_height=$height*$percent;

?>

——————————————————————————————————————————————————————–

Leave a Reply

Your email address will not be published. Required fields are marked *