fix: 이미지에디터(paintweb) 이미지 loading시 image size rate 조정

main
minuk926 2 years ago
parent 8a58fb179d
commit 16fede1a50

@ -298,7 +298,7 @@
switch (flag) { switch (flag) {
case "imageEditor": case "imageEditor":
url = '<c:url value="/framework/biz/cmm/file/cmmPaintwebImageEditorPopup.do"/>'; url = '<c:url value="/framework/biz/cmm/file/cmmPaintwebImageEditorPopup.do"/>';
popOption = {width: 1000, height: 800, resizable:false,scrollbars:'no'}; popOption = {width: 900, height: 750, resizable:false,scrollbars:'no'};
popTitle = "이미지 에디터"; popTitle = "이미지 에디터";
break; break;
case "imageView": case "imageView":

@ -68,7 +68,7 @@
* @type String * @type String
* @default "400px" * @default "400px"
*/ */
"viewportHeight": "630px", "viewportHeight": "620px",
/** /**
* Image save quality for the JPEG format. * Image save quality for the JPEG format.
@ -92,7 +92,7 @@
* @type Number * @type Number
* @default 300 * @default 300
*/ */
"imageHeight": 800, "imageHeight": 750,
/** /**
* Image preload. The image you want to display when PaintWeb loads. This must * Image preload. The image you want to display when PaintWeb loads. This must
@ -185,7 +185,7 @@
* @default 4 * @default 4
*/ */
// 4 means 400% zoom. // 4 means 400% zoom.
"imageZoomMax": 4, "imageZoomMax": 2,
/** /**
* The minimum allowed image zoom level. * The minimum allowed image zoom level.

@ -908,20 +908,59 @@ function PaintWeb (win, doc) {
alert(lang.imageLoadDifferentHost); alert(lang.imageLoadDifferentHost);
} }
//---------------------------------------------------------------------------------------
// FIXME : image size 조정
// if (imageLoad) {
// width = parseInt(imageLoad.width);
// height = parseInt(imageLoad.height);
// }
const imgWidth = parseInt(imageLoad.width);
const imgHeight = parseInt(imageLoad.height);
let scaleRate = 1.0;
if (imageLoad) { if (imageLoad) {
width = parseInt(imageLoad.width); if(imgWidth > width){
height = parseInt(imageLoad.height); scaleRate = width / imgWidth;
width = Math.floor(imgWidth * scaleRate);
height = Math.floor(imgHeight * scaleRate);
// viewportHeight": "620px" 설정에 맞게 set
if(height > 620){
scaleRate = 620 / height;
width = Math.floor(width * scaleRate);
height = Math.floor(height * scaleRate);
}
}
if(imgHeight > height){
scaleRate = height / imgHeight;
width = Math.floor(imgWidth * scaleRate);
height = Math.floor(imgHeight * scaleRate);
if(width > cfg.imageWidth){
scaleRate = cfg.imageWidth / width;
width = Math.floor(width * scaleRate);
height = Math.floor(height * scaleRate);
}
} }
}
//----------------------------------------------------------------------------------
res.elem = resInfo; res.elem = resInfo;
this.image.width = layerCanvas.width = bufferCanvas.width = width; this.image.width = layerCanvas.width = bufferCanvas.width = width;
this.image.height = layerCanvas.height = bufferCanvas.height = height; this.image.height = layerCanvas.height = bufferCanvas.height = height;
this.layer.canvas = layerCanvas; this.layer.canvas = layerCanvas;
this.layer.context = layerContext; this.layer.context = layerContext;
this.buffer.canvas = bufferCanvas; this.buffer.canvas = bufferCanvas;
this.buffer.context = bufferContext; this.buffer.context = bufferContext;
//---------------------------------------------------------------------------------------
// FIXME : image size 조정
this.layer.context.scale(scaleRate, scaleRate);
//---------------------------------------------------------------------------------------
if (imageLoad) { if (imageLoad) {
layerContext.drawImage(imageLoad, 0, 0); layerContext.drawImage(imageLoad, 0, 0);

Loading…
Cancel
Save