Browse Source

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

tif解析支持 伪格式的(比如jpg 修改后缀)

Signed-off-by: 高雄 <admin@cxcp.com>
pull/249/head
高雄 1 year ago committed by Gitee
parent
commit
355a69b4fc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
  1. 46
      server/src/main/resources/web/tiff.ftl

46
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>";
@ -86,9 +109,9 @@ html += " <p>有任何疑问,请加入kk开源社区知识星球咨询:<a
html += "</div>";
html += "</body>";
html += "</html>";
document.write(html);
document.close();
return;
document.write(html);
document.close();
return;
}
for (let i = 0; i < rgba.length; i++) {
imageData.data[i] = rgba[i];
@ -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