当前位置: 首页>>代码示例>>Java>>正文


Java ImageFormat.IMAGE_FORMAT_UNKNOWN属性代码示例

本文整理汇总了Java中org.apache.sanselan.ImageFormat.IMAGE_FORMAT_UNKNOWN属性的典型用法代码示例。如果您正苦于以下问题:Java ImageFormat.IMAGE_FORMAT_UNKNOWN属性的具体用法?Java ImageFormat.IMAGE_FORMAT_UNKNOWN怎么用?Java ImageFormat.IMAGE_FORMAT_UNKNOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.sanselan.ImageFormat的用法示例。


在下文中一共展示了ImageFormat.IMAGE_FORMAT_UNKNOWN属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canRead

@Override
public boolean canRead(final InputStream stream, final String name) {
	try {
		final ByteSource src = new ByteSourceInputStream(stream, name);

		return Sanselan.guessFormat(src) != ImageFormat.IMAGE_FORMAT_UNKNOWN;
	} catch (final Exception e) {
		return false;
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:10,代码来源:ImageUtilities.java

示例2: rewriteProxiedImage

/**
 * We don't actually rewrite the image we just ensure that it is in fact a valid
 * and known image type.
 */
private boolean rewriteProxiedImage(HttpRequest request, HttpResponse resp,
    MutableContent content) {
  boolean imageIsSafe = false;
  try {
    String contentType = resp.getHeader("Content-Type");
    if (contentType == null || contentType.toLowerCase().startsWith("image/")) {
      // Unspecified or unknown image mime type.
      try {
        ImageFormat imageFormat = Sanselan
        .guessFormat(new ByteSourceInputStream(resp.getResponse(),
            request.getUri().getPath()));
        if (imageFormat == ImageFormat.IMAGE_FORMAT_UNKNOWN) {
          logger.log(Level.INFO, "Unable to sanitize unknown image type "
              + request.getUri().toString());
          return true;
        }
        imageIsSafe = true;
        // Return false to indicate that no rewriting occurred
        return false;
      } catch (IOException ioe) {
        throw new RuntimeException(ioe);
      } catch (ImageReadException ire) {
        // Unable to read the image so its not safe
        logger.log(Level.INFO, "Unable to detect image type for " +request.getUri().toString() +
            " for sanitized content", ire);
        return true;
      }
    } else {
      return true;
    }
  } finally {
    if (!imageIsSafe) {
      content.setContent("");
    }
  }
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:40,代码来源:SanitizingRequestRewriter.java

示例3: MyImageReader

private MyImageReader(final SanselanImageReaderSpi provider, final ImageFormat imageFormat) {
  super(provider);
  myDefaultFormat = imageFormat == null? ImageFormat.IMAGE_FORMAT_UNKNOWN : imageFormat;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:SanselanImageReaderSpi.java


注:本文中的org.apache.sanselan.ImageFormat.IMAGE_FORMAT_UNKNOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。