cheditor 5.1.9.4 버전 업데이트

This commit is contained in:
kir rio
2023-01-11 10:21:44 +09:00
parent 7516424989
commit d99641d122
12 changed files with 335 additions and 187 deletions

View File

@ -36,7 +36,8 @@ var activeImage = null,
uploadImagePath = '',
uploadMaxNumber = 12,
uploadScript,
useWebGL = false;
useWebGL = false,
supportImageOrientation;
if (ArrayBuffer && !ArrayBuffer.prototype.slice) {
ArrayBuffer.prototype.slice = function (start, end) {
@ -437,11 +438,6 @@ function fileFilterError(file) {
"gif, png, jpg, webp 사진 파일만 전송할 수 있습니다.");
}
function explorerFileFilterError(file) {
alert("선택하신 '" + file + "' 파일은 전송할 수 없습니다.\n" +
"익스플로러 환경에서는 gif, png, jpg 사진 파일만 \n전송할 수 있습니다.");
}
function imgComplete(img, imgSize, boxId) {
var resizeW, resizeH, M, elem;
img.setAttribute("border", '0');
@ -929,7 +925,7 @@ function DoUpload() {
blob = new Blob();
for (key in blob) {
if (blob.hasOwnProperty(key)) {
if ({}.hasOwnProperty.call(blob, key)) {
(function (key) {
Object.defineProperty(MYBLOB.prototype,
key,
@ -967,13 +963,7 @@ DoUpload.prototype = {
file = files[i];
if (!file.type.match(fileTypeRe)) {
// 엣지를 제외한 ie브라우저인지 체크
var agent = navigator.userAgent.toLowerCase();
if (agent.indexOf('trident') != -1 || agent.indexOf("msie") != -1) {
explorerFileFilterError(file.name);
} else {
FileFilterError(file.name);
}
fileFilterError(file.name);
continue;
}
this.list.push(file);
@ -1032,15 +1022,22 @@ DoUpload.prototype = {
offset = 2,
marker, little, tags, i;
// JPEG가 아닌 경우, 알 수 없음
if (view.getUint16(0, false) !== 0xffd8) {
return -2;
}
while (offset < length) {
// 알 수 없음
if (view.getUint16(offset + 2, false) <= 8) {
return -1;
}
marker = view.getUint16(offset, false);
offset += 2;
if (marker === 0xffe1) {
// 알 수 없음
if (view.getUint32(offset += 2, false) !== 0x45786966) {
return -1;
}
@ -1061,7 +1058,7 @@ DoUpload.prototype = {
offset += view.getUint16(offset, false);
}
}
// 알 수 없음
return -1;
},
@ -1076,7 +1073,7 @@ DoUpload.prototype = {
|| window.MSBlobBuilder;
if (e.name === 'TypeError' && window.BlobBuilder) {
blobb = new BlobBuilder();
// eslint-disable-next-line no-undef
blobb.append(data);
blob = blobb.getBlob(datatype);
console.log("TypeError");
@ -1089,50 +1086,46 @@ DoUpload.prototype = {
return blob;
},
imageResize : function (image, filetype, resizeWidth, orientation, addWaterMark) {
var canvas, source_w = image.width, source_h = image.height,
resize_h, resize_w, ratio_w, ratio_h, ratio_w_half, ratio_h_half,
imageResize : function (image, filetype, resize_w, orientation, addWaterMark) {
var canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d"),
source_w = image.width,
source_h = image.height,
resize_h, ratio_w, ratio_h, ratio_w_half, ratio_h_half,
source_img, resize_img, source_data, resize_data, j, i,
x2, weight, weights, weights_alpha, gx_a, gx_b, gx_g, gx_r, center_x, center_y, x_start, x_stop,
y_start, y_stop, y, dy, part_w, x, dx, w, pos_x,
ctx, gl, imageData = null;
x2, weight, weights, weights_alpha, gx_a, gx_b, gx_g, gx_r,
center_x, center_y, x_start, x_stop,
y_start, y_stop, y, dy, part_w, x, dx, w, pos_x, gl, imageData = null;
// 카메라 로테이션 보정
if (orientation > 0) {
canvas = document.createElement("canvas");
canvas.width = source_w;
canvas.height = source_h;
ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.save();
if (orientation > 0 && !supportImageOrientation) {
if ([5,6,7,8].indexOf(orientation) > -1) {
canvas.width = source_h;
canvas.height = source_w;
} else {
canvas.width = source_w;
canvas.height = source_h;
}
switch (orientation) {
case 2 :
ctx.translate(-1, 0, 0, 1, canvas.width, 0); break;
case 3 :
ctx.translate(-1, 0, 0, -1, canvas.width, canvas.height); break;
case 4 :
ctx.translate(1, 0, 0, -1, 0, canvas.height); break;
case 5 :
ctx.translate(0, 1, 1, 0, 0, 0); break;
case 6 :
ctx.translate(0, 1, -1, 0, canvas.height, 0); break;
case 7 :
ctx.translate(0, -1, -1, 0, canvas.height, canvas.width); break;
case 8 :
ctx.translate(0, -1, 1, 0, 0, canvas.width); break;
case 2 : ctx.transform(-1, 0, 0, 1, source_w, 0); break;
case 3 : ctx.transform(-1, 0, 0, -1, source_w, source_h); break;
case 4 : ctx.transform(1, 0, 0, -1, 0, source_h); break;
case 5 : ctx.transform(0, 1, 1, 0, 0, 0); break;
case 6 : ctx.transform(0, 1, -1, 0, source_h, 0); break;
case 7 : ctx.transform(0, -1, -1, 0, source_h, source_w); break;
case 8 : ctx.transform(0, -1, 1, 0, 0, source_w); break;
default: break;
}
ctx.drawImage(image, 0, 0);
ctx.drawImage(image, 0, 0, source_w, source_h);
imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
ctx.restore();
source_w = canvas.width;
source_h = canvas.height;
}
if (source_w > resizeWidth) {
resize_w = resizeWidth;
if (source_w > resize_w) {
resize_h = Math.ceil(resize_w / source_w * source_h);
try {
@ -1143,8 +1136,6 @@ DoUpload.prototype = {
canvas = gl_canvas;
});
} catch (ignore) {
canvas = document.createElement("canvas");
ctx = canvas.getContext("2d");
canvas.width = source_w;
canvas.height = source_h;
@ -1216,14 +1207,10 @@ DoUpload.prototype = {
canvas.height = resize_h;
ctx.putImageData(resize_img, 0, 0);
}
} else {
canvas = document.createElement("canvas"),
canvas.width = source_w; canvas.height = source_h;
ctx = canvas.getContext("2d");
canvas.width = source_w;
canvas.height = source_h;
ctx.drawImage(image, 0, 0);
resize_h = source_h;
resize_w = source_w;
}
if (this.reader.watermark && addWaterMark) {
@ -1276,7 +1263,8 @@ DoUpload.prototype = {
filename = evt.target.file.name,
filetype = evt.target.file.type,
file = evt.target.file,
blob, image, orientation = 1, slice = 64 * 1024;
blob, image, orientation = 1,
slice = 64 * 1024;
if (slice > file.size - 1) {
slice = file.size;
@ -1298,12 +1286,12 @@ DoUpload.prototype = {
xhr.open('POST', uploadScript, true);
if (imageResizeWidth > 0) {
fileFormat = filename.substring(filename.lastIndexOf('.'));
if (imageResizeWidth > 0 && fileFormat !== '.gif') {
bitmapData = self.imageResize(this, filetype, imageResizeWidth, orientation, true);
file = self.canvasToBlob(bitmapData, filetype);
}
fileFormat = filename.substring(filename.lastIndexOf('.'));
randomName = self.makeFilename(fileFormat);
data.append('origname', filename);
@ -1375,7 +1363,6 @@ DoUpload.prototype = {
blob = null;
xhr.send(data);
};
image.src = blob.getURL();
}
},
@ -1484,7 +1471,7 @@ function setResizeWidth() {
}
function init(dialog) {
var dlg, i, elem, input, select, value, name, xhr_f, xhr_v, tmpcanvas, glicon;
var dlg, i, elem, input, select, value, name, xhr_f, xhr_v, tmpcanvas, glicon, testImg;
oEditor = this;
oEditor.dialog = dialog;
@ -1588,8 +1575,24 @@ function init(dialog) {
xhr_f.send();
xhr_v.send();
}
glicon = new Image();
glicon.className = 'webgl_logo';
glicon.src = uploadImagePath + (useWebGL ? "/webgl.png" : "/webgl-off.png");
document.getElementById('webgl_logo_wrapper').appendChild(glicon);
// 브라우저가 사진 Orientation 보정을 자동으로 지원하지는지 확인
testImg = new Image();
testImg.onload = function () {
supportImageOrientation = testImg.width === 2 && testImg.height === 3;
};
testImg.src =
'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' +
'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' +
'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' +
'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/x' +
'ABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAA' +
'AAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQ' +
'voP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXw' +
'H/9k=';
}