日期:2014-05-18  浏览次数:20644 次

高手请进,100分求解生成 清晰缩略图 的方法

        我刚接触web开发,用sun自带的包生成缩略图,生成尺寸小于   100   *   100的图非常模糊,几乎没办法接受,我在csdn上找了个用ImageMagic的配置方法(http://blog.csdn.net/tomyguan/archive/2006/12/30/1469003.aspx),在windows上配完之后运行出错:

#
#   An   unexpected   error   has   been   detected   by   HotSpot   Virtual   Machine:
#
#     EXCEPTION_ACCESS_VIOLATION   (0xc0000005)   at   pc=0x7c931c48,   pid=504,   tid=3828
#
#   Java   VM:   Java   HotSpot(TM)   Client   VM   (1.5.0_08-b03   mixed   mode,   sharing)
#   Problematic   frame:
#   C     [ntdll.dll+0x11c48]
#
#   An   error   report   file   with   more   information   is   saved   as   hs_err_pid504.log
#
#   If   you   would   like   to   submit   a   bug   report,   please   visit:
#       http://java.sun.com/webapps/bugreport/crash.jsp
#

[error   occurred   during   error   reporting,   step   270,   id   0xc0000005]

        有人用过这个工具吗?知道这个错误怎么引起的,怎么解决嘛?
        是不是还有更好的生成缩略图的办法,在线等待!

------解决方案--------------------
學習一下。。。
------解决方案--------------------
对于尺寸较大的图,直接缩小,难免失真变形。
可以逐级缩小试试效果,即先缩小70%,对结果图再缩小80%,直到接近要求值.
不过对于原尺寸远大小100×100的图,除非其图案本身就非常简单(一根粗直线或一个大圆之类的),否则,缩这么小一般都无法与原图相辨认了。
------解决方案--------------------
图像缩放,有很多算法,的确有些算法是不错的。但楼主似乎更需要一种封装好的、拿过来就能用的。这方面可以到sourceforge一些网点查查。

图像的尺寸,如okcome(流云)所说,如果比例差距较大而且图像细碎繁杂,无论如何也好不了。
------解决方案--------------------
http://www.wave12.com/web/home.asp

缩略图水印组件wsImage3.5

------解决方案--------------------
mark
------解决方案--------------------
import javax.imageio.ImageIO;
import javax.imageio.IIOException;
import java.awt.image.BufferedImage;
import java.awt.Image;
import java.io.File;
import java.awt.image.AffineTransformOp;
import java.awt.geom.AffineTransform;

public class convertImage {


private String fileInput ;
private String fileOutput ;

public convertImage()
{

}
public String getFileInput() {
return fileInput;
}
public void setFileInput(String fileInput) {
this.fileInput = fileInput;
}
public String getFileOutput() {
return fileOutput;
}
public void setFileOutput(String fileOutput) {
this.fileOutput = fileOutput;
}

public void convert()
{
try {
File fi = new File(fileInput);
File fo = new File(fileOutput);
int nw = 100;
int nh = 60;
AffineTransform transform = new AffineTransform();
BufferedImage bis = ImageIO.read(fi);
int w = bis.getWidth();
int h = bis.getHeight();

double sx = (double)nw/w;
double sy = (double)nh/h ;

if ( w > h )
{
if ( (int)(sx * h ) > nh )
{
sx = sy ;
nw = (int)(w*sx) ;
}
else
{
sy = sx ;
nh = (int)( h*sy) ;
}
}
else
{