优化
This commit is contained in:
@@ -32,6 +32,8 @@ public class MediaTypes {
|
|||||||
|
|
||||||
public static final MediaType SVG = new MediaType("image/svg+xml", ".svg");
|
public static final MediaType SVG = new MediaType("image/svg+xml", ".svg");
|
||||||
|
|
||||||
|
public static final MediaType WEBP = new MediaType("image/webp", ".webp");
|
||||||
|
|
||||||
// fonts
|
// fonts
|
||||||
public static final MediaType TTF = new MediaType(
|
public static final MediaType TTF = new MediaType(
|
||||||
"application/x-truetype-font", ".ttf");
|
"application/x-truetype-font", ".ttf");
|
||||||
@@ -56,7 +58,7 @@ public class MediaTypes {
|
|||||||
public static final MediaType UNKNOWN = new MediaType("application/octet-stream", "");
|
public static final MediaType UNKNOWN = new MediaType("application/octet-stream", "");
|
||||||
|
|
||||||
public static final MediaType[] mediaTypes = new MediaType[]{
|
public static final MediaType[] mediaTypes = new MediaType[]{
|
||||||
XHTML, EPUB, JPG, PNG, GIF, CSS, SVG, TTF, NCX, XPGT, OPENTYPE, WOFF,
|
XHTML, EPUB, JPG, PNG, GIF, WEBP, CSS, SVG, TTF, NCX, XPGT, OPENTYPE, WOFF,
|
||||||
SMIL, PLS, JAVASCRIPT, MP3, MP4, OGG, UNKNOWN
|
SMIL, PLS, JAVASCRIPT, MP3, MP4, OGG, UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +71,11 @@ public class MediaTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBitmapImage(MediaType mediaType) {
|
public static boolean isBitmapImage(MediaType mediaType) {
|
||||||
return mediaType == JPG || mediaType == PNG || mediaType == GIF;
|
return mediaType == JPG || mediaType == PNG || mediaType == GIF || mediaType == WEBP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isImage(MediaType mediaType) {
|
||||||
|
return mediaType == JPG || mediaType == PNG || mediaType == GIF || mediaType == SVG || mediaType == WEBP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class PackageDocumentReader extends PackageDocumentBase {
|
|||||||
//如果有图片资源未定义在 originItemElements ,则加入该图片信息得到 fixedElements 中
|
//如果有图片资源未定义在 originItemElements ,则加入该图片信息得到 fixedElements 中
|
||||||
for (Resource resource : resources.getAll()) {
|
for (Resource resource : resources.getAll()) {
|
||||||
MediaType currentMediaType = resource.getMediaType();
|
MediaType currentMediaType = resource.getMediaType();
|
||||||
if (currentMediaType == MediaTypes.JPG || currentMediaType == MediaTypes.PNG) {
|
if (MediaTypes.isImage(currentMediaType)) {
|
||||||
String imageHref = resource.getHref();
|
String imageHref = resource.getHref();
|
||||||
//确保该图片信息 resource 在原 originItemHrefSet 集合中没有出现过
|
//确保该图片信息 resource 在原 originItemHrefSet 集合中没有出现过
|
||||||
if (!originItemHrefSet.contains(imageHref)) {
|
if (!originItemHrefSet.contains(imageHref)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user