java读取TIF,TIFF文件方法
-11-25
private void isAsyuku() throws Exception {
InputStream file = upFile.getInputstream();
int index = StringUtils.split(upFile.getFileName(), "\\").length - 1;
String fileName1 = StringUtils.split(upFile.getFileName(), "\\")[index];
if(StringUtils.split(fileName1, ".").length == 1){
return;
}
String extension = StringUtils.split(fileName1, ".")[1];
StringUtils.equals(extension, "");
if (StringUtils.equals(extension, "gif") || StringUtils.equals(extension, "bmp")
|| StringUtils.equals(extension, "jpg") || StringUtils.equals(extension, "tif")
|| StringUtils.equals(extension, "tiff") || StringUtils.equals(extension, "GIF")
|| StringUtils.equals(extension, "BMP") || StringUtils.equals(extension, "JPG")
|| StringUtils.equals(extension, "TIF") || StringUtils.equals(extension, "TIFF")) {
if (StringUtils.equals(extension, "TIFF") || StringUtils.equals(extension, "TIF")
|| StringUtils.equals(extension, "tif") || StringUtils.equals(extension, "tiff")) {
IIORegistry registry = IIORegistry.getDefaultInstance();
registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriterSpi());
registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi());
}
// ファイルのピクセールサイズを取得する
BufferedImage image = ImageIO.read(file);
BigDecimal width = BigDecimal.valueOf(image.getWidth());
BigDecimal height = BigDecimal.valueOf(image.getHeight());
if (pareTo(new BigDecimal(5000)) > 0 || pareTo(new BigDecimal(5000)) > 0) {
this.imageFlage = "true";
} else {
this.imageFlage = "false";
}
}
}
免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。
/style/images/nopic.gif