Browse Source

!249 tif解析更加智能化 支持被修改的图片格式

Merge pull request !249 from 高雄/N/A
pull/243/MERGE
kailing 1 year ago committed by Gitee
parent
commit
a95dda6c20
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
  1. 40
      server/src/main/resources/web/tiff.ftl

40
server/src/main/resources/web/tiff.ftl

@ -28,6 +28,21 @@
</#if>
<div id="tiff"></div>
<script>
String.prototype.startsWithh = function(str) {
var reg = new RegExp("^" + str);
return reg.test(this);
}
String.prototype.endsWithh = function(str) {
var reg = new RegExp(str + "$");
return reg.test(this);
}
var url = '${finalUrl}';
var baseUrl = '${baseUrl}'.endsWithh('/') ? '${baseUrl}' : '${baseUrl}' + '/';
if (!url.startsWithh(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
}
var myp = document.getElementById('tiff');
let pages;
let p;
let resp;
@ -42,6 +57,14 @@
try{
imageData = ctx.createImageData(canvas.width, canvas.height);
} catch(e){
if (e.message.indexOf("CanvasRenderingContext2D"))
{
var imgObjj = new Image();
imgObjj.src = url;
myp.appendChild(imgObjj);
console.log("错误:" + e);
return;
}
console.log("错误:" + e);
var html = "";
html += "<head>";
@ -99,7 +122,6 @@ return;
if (++p < pages.length) {
imgObj.onload = loadOne;
}
var myp = document.getElementById('tiff');
myp.appendChild(imgObj);
}
@ -109,22 +131,6 @@ return;
p = 0;
loadOne();
}
String.prototype.startsWithh = function(str) {
var reg = new RegExp("^" + str);
return reg.test(this);
}
String.prototype.endsWithh = function(str) {
var reg = new RegExp(str + "$");
return reg.test(this);
}
var url = '${finalUrl}';
var baseUrl = '${baseUrl}'.endsWithh('/') ? '${baseUrl}' : '${baseUrl}' + '/';
if (!url.startsWithh(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
}
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'arraybuffer';

Loading…
Cancel
Save