Skip to content

Commit

Permalink
!249 tif解析更加智能化 支持被修改的图片格式
Browse files Browse the repository at this point in the history
Merge pull request !249 from 高雄/N/A
  • Loading branch information
klboke authored and gitee-org committed Nov 6, 2023
2 parents 790c29c + 355a69b commit a95dda6
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions server/src/main/resources/web/tiff.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>";
Expand Down Expand Up @@ -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];
Expand All @@ -99,7 +122,6 @@ return;
if (++p < pages.length) {
imgObj.onload = loadOne;
}
var myp = document.getElementById('tiff');
myp.appendChild(imgObj);
}

Expand All @@ -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';
Expand Down

0 comments on commit a95dda6

Please sign in to comment.