【问题标题】:To view Tiff image on web and do image processing on it using java applet在 Web 上查看 Tiff 图像并使用 java 小程序对其进行图像处理
【发布时间】:2016-07-26 10:41:00
【问题描述】:

我想使用 HTML 和 Javascript 在 Web 上浏览和显示大的 Tiff 图像,并使用 java 小程序对其进行图像处理。

所有的图像加载和处理都应该在客户端机器上。 为了查看图像,我想使用 HTML 和 Javascript。

对于图像处理,我想使用 java 小程序。

【问题讨论】:

  • 这不是一个问题,更像是对您想要创建的内容的陈述。我确信 JS 也有 TIFF 库,但如果你真的想走小程序路线,你应该尝试实现上面概述的内容。如果您在实施时遇到问题,请回来并ask for help 解决具体问题。

标签: java html applet tiff jai


【解决方案1】:

我的脸和你的脸一样。众所周知,tiff 图像在 Web 浏览器上是不可见的。所以我们必须转换成Png或任何其他格式。

File file = new File(path_of_tiff_file, name_of_tiff_file);
String newName = file.getName();
// if (!file.exists()) {
        item.write(file);
        if(item.getName().toLowerCase().indexOf(".tif") >=0 || item.getName().toLowerCase().indexOf(".tiff") >=0 ){

                            newName =item.getName().subSequence(0, item.getName().lastIndexOf(".")) + ".png";
                            File newFile = new File(path , newName);
                            BufferedImage image= null;
                            try {
                                image = Sanselan.getBufferedImage(file);
                            } catch (Exception e) {
                                // TODO: handle exception
                                e.printStackTrace();
                            }
                            Sanselan.writeImage(image, newFile, ImageFormat.IMAGE_FORMAT_PNG, new Hashtable());
                        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    相关资源
    最近更新 更多