简体   繁体   中英

how to resize an image and make it smooth like original

i have an image which width is 213 and height is 200 when i echo the image from my database and i resize it (echo "<img src='company/$present' width='70' height='68'/>";) the image was not as clear as when it was 213 * 200. how can i make the image smooth like the original after i have resize it to 70 * 68 or rather when i increase above 213 * 200.

<?php
    $query = "SELECT * FROM photo";
    $result = mysql_query ($query) or die('query error');
    $count = 0;
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
    $image = $line[picname];
    echo "<img src='company/$image'/> ";
    $count++;
    }
   ?>

how can i make the image smooth like the original after i have resize it to 70 * 68 or rather when i increase above 213 * 200.

Internet Explorer in particular seems to use a nasty algorithm for sizing images down. You'd be best off using a toolkit like ImageMagick or PHP's GD to size the image on the server-side.

Nothing's going to make upscaling look good.

Add the CSS tag img { -ms-interpolation-mode: bicubic; } img { -ms-interpolation-mode: bicubic; } to choose smoother resizing in Internet Explorer 7. IE8 already uses this by default. I don't remember if it works in IE6.

As a general rule don't set both the width and the height explicitly for the image. It becomes very difficult to maintain the aspect ratio of the image that way.

最好的方法是保持图像的纵横比,所以基本上如果图像是800 x 1200,而不是将其调整到某个像素大小,按百分比进行,并确保宽度和高度改变相同的百分比。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM