如何调整图像大小并使其像原始图像一样平滑
当我从数据库中回显图像并调整其大小时,我有一个宽度为 213、高度为 200 的图像 (echo "";)
图像不像 213 * 200 时那么清晰。在将其大小调整为 70 * 68 后,或者当我增加到以上时,如何才能使图像像原始图像一样平滑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++;
}
?>
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++;
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
。特别是 Internet Explorer 似乎使用一种令人讨厌的算法来缩小图像大小。您最好使用 ImageMagick 或 PHP 的 GD 等工具包在服务器端调整图像大小。
没有什么能让升级看起来很好。
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.
添加 CSS 标签
img { -ms-interpolation-mode: bicubic; }
在 Internet Explorer 7 中选择更平滑的调整大小。IE8 已默认使用此功能。我不记得它在 IE6 中是否有效。Add the CSS tag
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 best way is to keep the images aspect ration, so basically if the image was 800 x 1200 , instead of resizing it to a certain pixel size do it by percent and make sure the width and height are being changed by the same percent.