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;