mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 12:30:00 +00:00
Fix #1255 (support webp in comic viewer)
This commit is contained in:
parent
376214e2d2
commit
123493ee59
@ -141,9 +141,24 @@ var createURLFromArray = function(array, mimeType) {
|
||||
kthoom.ImageFile = function(file) {
|
||||
this.filename = file.filename;
|
||||
var fileExtension = file.filename.split(".").pop().toLowerCase();
|
||||
this.mimeType = fileExtension === "png" ? "image/png" :
|
||||
(fileExtension === "jpg" || fileExtension === "jpeg") ? "image/jpeg" :
|
||||
fileExtension === "gif" ? "image/gif" : fileExtension === "svg" ? "image/xml+svg" : undefined;
|
||||
switch (fileExtension) {
|
||||
case "jpg":
|
||||
case "jpeg":
|
||||
this.mimeType = "image/jpeg";
|
||||
break;
|
||||
case "gif":
|
||||
this.mimeType = "iamge/gif";
|
||||
break;
|
||||
case "svg":
|
||||
this.mimeType = "image/svg+xml";
|
||||
break;
|
||||
case "webp":
|
||||
this.mimeType = "image/webp";
|
||||
break;
|
||||
default:
|
||||
this.mimeType = undefined;
|
||||
break;
|
||||
}
|
||||
if ( this.mimeType !== undefined) {
|
||||
this.dataURI = createURLFromArray(file.fileData, this.mimeType);
|
||||
this.data = file;
|
||||
@ -336,7 +351,7 @@ function setImage(url) {
|
||||
$("#mainText").innerHTML("<iframe style=\"width:100%;height:700px;border:0\" src=\"data:text/html," + escape(xhr.responseText) + "\"></iframe>");
|
||||
};
|
||||
xhr.send(null);
|
||||
} else if (!/(jpg|jpeg|png|gif)$/.test(imageFiles[currentImage].filename) && imageFiles[currentImage].data.uncompressedSize < 10 * 1024) {
|
||||
} else if (!/(jpg|jpeg|png|gif|webp)$/.test(imageFiles[currentImage].filename) && imageFiles[currentImage].data.uncompressedSize < 10 * 1024) {
|
||||
xhr.open("GET", url, true);
|
||||
xhr.onload = function() {
|
||||
$("#mainText").css("display", "");
|
||||
|
@ -560,7 +560,7 @@ def get_comic_book(book_id, book_format, page):
|
||||
else:
|
||||
b64 = extract(page).encode('base64')
|
||||
ext = names[page].rpartition('.')[-1]
|
||||
if ext not in ('png', 'gif', 'jpg', 'jpeg'):
|
||||
if ext not in ('png', 'gif', 'jpg', 'jpeg', 'webp'):
|
||||
ext = 'png'
|
||||
extractedfile="data:image/" + ext + ";base64," + b64
|
||||
fileData={"name": names[page], "page":page, "last":len(names)-1, "content": extractedfile}
|
||||
|
Loading…
Reference in New Issue
Block a user