Changeset 3370

Show
Ignore:
Timestamp:
05/27/07 06:41:11 (3 years ago)
Author:
graphittie
Message:

#377 : 리샘플링 기능이 완벽하지 못함.

  • 리샘플링과 워터마크의 분리. 워터마크 루틴을 제거함. TODO : 워터마크 기능은 플러그인으로 구현할 것.
  • 에디터의 이미지 속성창의 리샘플링, 워터마크 체크박스 제거. 이로서 리샘플링은 중앙설정에서 켜고 끄는 것으로 전체 이미지를 제어하게 됨.
  • 환경설정>글쓰기>리샘플링에서 워터마크, 여백 관련 설정부분을 제거.
  • Textcube.Function.Image.php에서 여백과 워터마크 관련 부분을 제거. 워터마크 관련 멤버함수는 추후 다음을 예정.
  • Textcube.Function.Image.php에서 BeforeReiszeImage, AfterResizeImage 이벤트를 주석처리. 이후 리샘플링은 모든 프로세스에서 독립된 기능으로 구현될 것임. Windows에서 썸네일 루틴이 explorer.exe에 포함되어 있고 이미지 프로세싱은 각 프로그램이 담당하고 있다는 점을 참고.
  • Textcube.Function.Image.php에서 checkExistingThumbnail() 함수를 제거.
  • makeThumbnail()을 resampleImage()로 명칭변경.
  • 워터마크, 여백 관련 글로벌 변수를 제거하고, 리샘플링 설정 글로벌 변수를 추가. 기존 루틴에서는 리샘플링을 이미지 하나하나 시도할 때마다 리샘플링 설정을 체크하고 있어 불필요한 쿼리를 발생시킴.
  • [3369]에서 이동된 루틴에 리샘플링 글로벌 설정을 체크하는 조건문 추가.
Location:
sandbox
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • sandbox/blog/owner/setting/entry/index.php

    r3138 r3370  
    6262                                                break; 
    6363                                        } 
    64                                     } 
    65                                 } 
    66                                  
    67                                 window.addEventListener("load", execLoadFunction, false); 
    68                                 function execLoadFunction() { 
    69                                     if (document.getElementById('topPadding').value != "direct") { 
    70                                         document.getElementById('topPadding').removeAttribute('disabled'); 
    71                                         document.getElementById('topPaddingManual').setAttribute('disabled', 'disabled'); 
    72                                     } else { 
    73                                         document.getElementById('topPadding').removeAttribute('disabled'); 
    74                                     } 
    75                                     if (document.getElementById('rightPadding').value != "direct") { 
    76                                         document.getElementById('rightPadding').removeAttribute('disabled'); 
    77                                         document.getElementById('rightPaddingManual').setAttribute('disabled', 'disabled'); 
    78                                     } else { 
    79                                         document.getElementById('rightPadding').removeAttribute('disabled'); 
    80                                     } 
    81                                     if (document.getElementById('bottomPadding').value != "direct") { 
    82                                         document.getElementById('bottomPadding').removeAttribute('disabled'); 
    83                                         document.getElementById('bottomPaddingManual').setAttribute('disabled', 'disabled'); 
    84                                     } else { 
    85                                         document.getElementById('bottomPadding').removeAttribute('disabled'); 
    86                                     } 
    87                                     if (document.getElementById('leftPadding').value != "direct") { 
    88                                         document.getElementById('leftPadding').removeAttribute('disabled'); 
    89                                         document.getElementById('leftPaddingManual').setAttribute('disabled', 'disabled'); 
    90                                     } else { 
    91                                         document.getElementById('leftPadding').removeAttribute('disabled'); 
    9264                                    } 
    9365                                } 
     
    169141                                            <dt><span class="label"><?php echo _t('기본 설정');?></span></dt> 
    170142                                            <dd> 
    171                                                 <input type="checkbox" class="checkbox" id="useResamplingAsDefault" name="useResamplingAsDefault" value="yes" onclick="if (this.checked == false && document.getElementById('useWatermarkAsDefault').checked == true) document.getElementById('useWatermarkAsDefault').checked = false;"<?php echo (getUserSetting("resamplingDefault") == "yes") ? ' checked="checked"' : NULL;?> /><label for="useResamplingAsDefault"><?php echo _t('이미지 리샘플링 기능을 기본으로 사용합니다. <em>이 기능 사용시 서버에 많은 부하가 걸릴 수 있으니 주의하시기 바랍니다.</em>');?></label><br /> 
    172 <?php 
    173     if (file_exists(ROOT."/attach/$owner/watermark.gif")) { 
    174 ?> 
    175                                                 <input type="checkbox" class="checkbox" id="useWatermarkAsDefault" name="useWatermarkAsDefault" value="yes" onclick="if (this.checked == true && document.getElementById('useResamplingAsDefault').checked == false) document.getElementById('useResamplingAsDefault').checked = true;"<?php echo (getUserSetting("waterMarkDefault") == "yes") ? ' checked="checked"' : NULL;?> /><label for="useWatermarkAsDefault"><?php echo _t('워터마크 기능을 기본으로 사용합니다.');?></label> 
    176 <?php 
    177     } 
    178 ?> 
    179                                             </dd> 
    180                                         </dl> 
    181                                         <dl id="watermark-line" class="line"> 
    182                                             <dt><span class="label"><?php echo _t('워터 마크');?></span></dt> 
    183                                             <dd> 
    184                                                 <p><?php echo _t('워터 마크는 그림이나 사진의 소유권을 표시하거나 위조를 방지하기 위하여 넣는 무늬입니다.');?></p> 
    185 <?php 
    186     if (file_exists(ROOT."/attach/$owner/watermark.gif")) {          
    187         $waterMarkInfo = getimagesize(ROOT."/attach/$owner/watermark.gif"); 
    188         if ($waterMarkInfo[0] > 150) { 
    189 ?> 
    190                                                 <a href="<?php echo $service['path'];?>/attach/<?php echo $owner;?>/watermark.gif?randomseed=<?php echo rand();?>" onclick="window.open(this.href); return false;"><img src="<?php echo $service['path'];?>/attach/<?php echo $owner;?>/watermark.gif?randomseed=<?php echo rand();?>" width="150" border="1" alt="<?php echo _t('워터마크 이미지');?>" /></a> 
    191 <?php 
    192         } else { 
    193 ?> 
    194                                                 <img src="<?php echo $service['path'];?>/attach/<?php echo $owner;?>/watermark.gif?randomseed=<?php echo rand();?>" border="1" alt="<?php echo _t('워터마크 이미지');?>" /> 
    195 <?php 
    196         } 
    197     } 
    198 ?> 
    199                                                 <br /><input type="file" class="input-file" name="waterMark" /><br /> 
    200                                                 <input type="checkbox" class="checkbox" id="deleteWaterMark" name="deleteWaterMark" value="yes"<?php echo file_exists(ROOT."/attach/$owner/watermark.gif") ? '' : ' disabled="disabled"';?> /><label for="deleteWaterMark"><?php echo _t('워터 마크를 초기화합니다.');?></label> 
    201                                             </dd> 
    202                                         </dl> 
    203 <?php 
    204     $waterMarkPosition = getUserSetting("waterMarkPosition", "left=10|bottom=10"); 
    205     $waterMarkPosition = explode("|", $waterMarkPosition); 
    206     parse_str($waterMarkPosition[0]); 
    207     parse_str($waterMarkPosition[1]); 
    208      
    209     if (isset($left)) 
    210         $horizontalValue = $left; 
    211     if (isset($right)) 
    212         $horizontalValue = $right; 
    213     if (isset($center)) 
    214         $horizontalValue = 0; 
    215     if (isset($top)) 
    216         $verticalValue = $top; 
    217     if (isset($bottom)) 
    218         $verticalValue = $bottom; 
    219     if (isset($middle)) 
    220         $verticalValue = 0; 
    221 ?> 
    222                                         <dl id="watermark-position-line" class="line"> 
    223                                             <dt><span class="label"><?php echo _t('워터마크 위치');?></span></dt> 
    224                                             <dd> 
    225                                                 <div id="vertical-position"> 
    226                                                     <select name="verticalType"<?php echo file_exists(ROOT."/attach/$owner/watermark.gif") ? '' : ' disabled="disabled"';?>> 
    227                                                         <option value="top"<?php echo isset($top) ? ' selected="selected"' : '';?>><?php echo _t('상단');?></option> 
    228                                                         <option value="middle"<?php echo isset($middle) ? ' selected="selected"' : '';?>><?php echo _t('중앙');?></option> 
    229                                                         <option value="bottom"<?php echo isset($bottom) ? ' selected="selected"' : '';?>><?php echo _t('하단');?></option> 
    230                                                     </select> 
    231                                                     <input type="text" class="input-text" name="verticalPosition" value="<?php echo $verticalValue;?>"<?php echo file_exists(ROOT."/attach/$owner/watermark.gif") ? '' : ' disabled="disabled"';?> />px 
    232                                                 </div> 
    233                                                 <div id="horizontal-position"> 
    234                                                     <select name="horizontalType"<?php echo file_exists(ROOT."/attach/$owner/watermark.gif") ? '' : ' disabled="disabled"';?>> 
    235                                                         <option value="left"<?php echo isset($left) ? ' selected="selected"' : '';?>><?php echo _t('좌측');?></option> 
    236                                                         <option value="center"<?php echo isset($center) ? ' selected="selected"' : '';?>><?php echo _t('중앙');?></option> 
    237                                                         <option value="right"<?php echo isset($right) ? ' selected="selected"' : '';?>><?php echo _t('우측');?></option> 
    238                                                     </select> 
    239                                                     <input type="text" class="input-text" name="horizontalPosition" value="<?php echo $horizontalValue;?>" <?php echo file_exists(ROOT."/attach/$owner/watermark.gif") ? '' : ' disabled="disabled"';?> />px 
    240                                                 </div> 
    241                                             </dd> 
    242                                         </dl> 
    243  
    244 <?php    
    245     $thumbnailPadding = getThumbnailPadding(); 
    246     $colorOfPadding = getThumbnailPaddingColor(); 
    247 ?> 
    248                                         <dl id="padding-line" class="line"> 
    249                                             <dt><span class="label"><?php echo _t('이미지 여백');?></span></dt> 
    250                                             <dd> 
    251 <?php 
    252     $paddingOrder = array("top", "bottom", "left", "right"); 
    253     $paddingText = array(_t('상단 여백'), _t('하단 여백'), _t('좌측 여백'), _t('우측 여백')); 
    254      
    255     for ($i=0; $i<count($paddingOrder); $i++) { 
    256         $tempIndex = $paddingOrder[$i]; 
    257 ?> 
    258                                                 <div id="<?php echo $paddingOrder[$i];?>-padding"> 
    259                                                     <span class="label"><?php echo $paddingText[$i];?></span> 
    260                                                     <select id="<?php echo $paddingOrder[$i];?>Padding" name="<?php echo $paddingOrder[$i];?>Padding" onchange="checkManualInput(this)" disabled="disabled"> 
    261                                                         <option value="0"<?php echo $thumbnailPadding[$tempIndex] == 0 ? ' selected="selected"' : '';?>>0px</option> 
    262                                                         <option value="5"<?php echo $thumbnailPadding[$tempIndex] == 5 ? ' selected="selected"' : '';?>>5px</option> 
    263                                                         <option value="10"<?php echo $thumbnailPadding[$tempIndex] == 10 ? ' selected="selected"' : '';?>>10px</option> 
    264                                                         <option value="15"<?php echo $thumbnailPadding[$tempIndex] == 15 ? ' selected="selected"' : '';?>>15px</option> 
    265                                                         <option value="20"<?php echo $thumbnailPadding[$tempIndex] == 20 ? ' selected="selected"' : '';?>>20px</option> 
    266                                                         <option value="25"<?php echo $thumbnailPadding[$tempIndex] == 25 ? ' selected="selected"' : '';?>>25px</option> 
    267                                                         <option value="direct"<?php echo !in_array($thumbnailPadding[$tempIndex], array(0, 5, 10, 15, 20, 25)) ? ' selected="selected"' : '';?>><?php echo _t('직접입력');?></option> 
    268                                                     </select> 
    269 <?php 
    270     $temp = $thumbnailPadding[$paddingOrder[$i]]; 
    271 ?> 
    272                                                     <input type="text" class="input-text" id="<?php echo $paddingOrder[$i];?>PaddingManual" name="<?php echo $paddingOrder[$i];?>PaddingManual" value="<?php echo $temp;?>" />px 
    273                                                 </div> 
    274 <?php 
    275     } 
    276 ?> 
    277                                                 <div id="padding-color"> 
    278                                                     <span class="label"><?php echo _t('여백 색상');?></span> 
    279                                                     <input type="text" class="input-text" name="paddingColor" value="<?php echo $colorOfPadding;?>" /> 
    280                                                 </div> 
     143                                                <input type="checkbox" class="checkbox" id="useResamplingAsDefault" name="useResamplingAsDefault" value="yes"<?php echo (getUserSetting("resamplingDefault") == "yes") ? ' checked="checked"' : NULL;?> /><label for="useResamplingAsDefault"><?php echo _t('이미지 리샘플링 기능을 기본으로 사용합니다.');?> <em><?php echo _t('이 기능 사용시 서버에 많은 부하가 걸릴 수 있으니 주의하시기 바랍니다.');?></em></label> 
    281144                                            </dd> 
    282145                                        </dl> 
  • sandbox/blog/owner/setting/entry/resample/index.php

    r3108 r3370  
    77$IV = array( 
    88    'POST' => array( 
    9         'deleteWaterMark' => array('string', 'default' => "no"), 
    10         'horizontalType' => array('string', 'default' => "left"), 
    11         'verticalType' => array('string', 'default' => "top"), 
    12         'horizontalPosition' => array('int', 'default' => 0), 
    13         'verticalPosition' => array('int', 'default' => 0), 
    14         'topPadding' => array('any', 'mandatory' => false), 
    15         'rightPadding' => array('any', 'mandatory' => false), 
    16         'bottomPadding' => array('any', 'mandatory' => false), 
    17         'leftPadding' => array('any', 'mandatory' => false), 
    18         'topPaddingManual' => array('int', 'mandatory' => false), 
    19         'rightPaddingManual' => array('int', 'mandatory' => false), 
    20         'bottomPaddingManual' => array('int', 'mandatory' => false), 
    21         'leftPaddingManual' => array('int', 'mandatory' => false), 
    22         'paddingColor' => array('string', 'default' => "FFFFFF"), 
    23         'useResamplingAsDefault' => array('string', 'mandatory' => false), 
    24         'useWatermarkAsDefault' => array('string', 'mandatory' => false) 
    25         ), 
    26     'FILES' => array( 
    27         'waterMark' => array('file', 'mandatory' => false) 
     9        'useResamplingAsDefault' => array('string', 'mandatory' => false) 
    2810        ) 
    2911    ); 
     
    3214 
    3315$isAjaxRequest = false; // checkAjaxRequest(); 
    34 $errorArray = array(); 
    3516 
    3617// 기본 설정 
    3718if (isset($_POST['useResamplingAsDefault']) && ($_POST['useResamplingAsDefault'] == "yes")) { 
    3819    setUserSetting("resamplingDefault", "yes"); 
    39 } else if (getUserSetting("resamplingDefault") == "yes") { 
     20} else { 
    4021    removeUserSetting("resamplingDefault"); 
    41     removeUserSetting("waterMarkDefault"); 
    42     deleteFilesByRegExp(ROOT."/cache/thumbnail/$owner/", ''); 
    4322} 
    44  
    45 if (isset($_POST['useWatermarkAsDefault']) && ($_POST['useWatermarkAsDefault'] == "yes")) { 
    46     setUserSetting("waterMarkDefault", "yes"); 
    47 } else  if (getUserSetting("waterMarkDefault") == "yes") { 
    48     removeUserSetting("waterMarkDefault"); 
    49     deleteFilesByRegExp(ROOT."/cache/thumbnail/$owner/", ''); 
    50 } 
    51  
    52 // 워터마크 처리. 
    53 if (isset($_POST['deleteWaterMark']) && ($_POST['deleteWaterMark'] == "yes")) { 
    54     unlink(ROOT."/attach/$owner/watermark.gif"); 
    55 } 
    56  
    57 // 업로드된 새 워터마크가 있는 경우. 
    58 if (!empty($_FILES['waterMark']['tmp_name'])) { 
    59     $fileExt = Path::getExtension($_FILES['waterMark']['name']); 
    60      
    61     if (!in_array($fileExt, array('.gif', '.jpg', '.png'))) { 
    62         if ($isAjaxRequest) { 
    63             printRespond(array('error' => 1, 'msg' => _t('변경하지 못했습니다.'))); 
    64         } 
    65         // TODO : --???? error handling needed 
    66         header("Location: ".$_SERVER['HTTP_REFERER']); 
    67         exit; 
    68     } else {  
    69         requireComponent('Textcube.Data.Attachment'); 
    70         Attachment::confirmFolder(); 
    71  
    72         if (move_uploaded_file($_FILES['waterMark']['tmp_name'], ROOT."/attach/$owner/watermark.gif")) { 
    73             @chmod(ROOT . "/attach/$owner/watermark.gif", 0666); 
    74             deleteAllThumbnails(ROOT."/cache/thumbnail/$owner"); 
    75         } 
    76     } 
    77 } else if (!file_exists(ROOT."/attach/$owner/watermark.gif")) { 
    78     $_POST['horizontalType'] = "left"; 
    79     $_POST['verticalType'] = "top"; 
    80     $_POST['horizontalPosition'] = "0"; 
    81     $_POST['verticalPosition'] = "0"; 
    82 } 
    83  
    84 $bErrorFlag = false; 
    85 if (!in_array(strtolower($_POST['verticalType']), array("top", "middle", "bottom"))) 
    86     $bErrorFlag = true; 
    87 if (!in_array(strtolower($_POST['horizontalType']), array("left", "center", "right"))) 
    88     $bErrorFlag = true; 
    89 if (!preg_match("/^[0-9]+$/", $_POST['verticalPosition'])) 
    90     $bErrorFlag = true; 
    91 if (!preg_match("/^[0-9]+$/", $_POST['horizontalPosition'])) 
    92     $bErrorFlag = true; 
    93  
    94 // 워터마크 포지션 값에 오류가 있으면 이전 값으로 되돌림. 
    95 if ($bErrorFlag == true) { 
    96     $errorArray['position'] = true; 
    97 } else { 
    98     $_POST['verticalPosition'] = preg_replace("/^0*/", '', $_POST['verticalPosition']); 
    99     $_POST['verticalPosition'] = empty($_POST['verticalPosition']) ? 0 : $_POST['verticalPosition']; 
    100     $_POST['horizontalPosition'] = preg_replace("/^0*/", '', $_POST['horizontalPosition']); 
    101     $_POST['horizontalPosition'] = empty($_POST['horizontalPosition']) ? 0 : $_POST['horizontalPosition']; 
    102      
    103     $strNewPosition = "{$_POST['horizontalType']}={$_POST['horizontalPosition']}|{$_POST['verticalType']}={$_POST['verticalPosition']}"; 
    104     $strOldPosition = getUserSetting("waterMarkPosition"); 
    105      
    106     if (is_null($strOldPosition) || $strNewPosition != $strOldPosition) { 
    107         setUserSetting('waterMarkPosition', $strNewPosition); 
    108         deleteAllThumbnails(ROOT."/cache/thumbnail/$owner"); 
    109     } 
    110 } 
    111      
    112 // 썸네일 여백. 
    113 if ($_POST['topPadding'] == "direct") 
    114     $_POST['topPadding'] = $_POST['topPaddingManual']; 
    115 if ($_POST['bottomPadding'] == "direct") 
    116     $_POST['bottomPadding'] = $_POST['bottomPaddingManual']; 
    117 if ($_POST['rightPadding'] == "direct") 
    118     $_POST['rightPadding'] = $_POST['rightPaddingManual']; 
    119 if ($_POST['leftPadding'] == "direct") 
    120     $_POST['leftPadding'] = $_POST['leftPaddingManual']; 
    121  
    122 $bErrorFlag = false; 
    123 if (!preg_match("/^[0-9]+$/", $_POST['topPadding'])) 
    124     $bErrorFlag = true; 
    125 if (!preg_match("/^[0-9]+$/", $_POST['bottomPadding'])) 
    126     $bErrorFlag = true; 
    127 if (!preg_match("/^[0-9]+$/", $_POST['rightPadding'])) 
    128     $bErrorFlag = true; 
    129 if (!preg_match("/^[0-9]+$/", $_POST['leftPadding'])) 
    130     $bErrorFlag = true; 
    131  
    132 // 썸네일 여백 값에 오류가 있으면 이전 값으로 되돌림. 
    133 if ($bErrorFlag == true) 
    134     $errorArray['padding'] = true; 
    135  
    136 if ($bErrorFlag == false) { 
    137     $_POST['topPadding'] = preg_replace("/^0*/", '', $_POST['topPadding']); 
    138     $_POST['bottomPadding'] = preg_replace("/^0*/", '', $_POST['bottomPadding']); 
    139     $_POST['rightPadding'] = preg_replace("/^0*/", '', $_POST['rightPadding']); 
    140     $_POST['leftPadding'] = preg_replace("/^0*/", '', $_POST['leftPadding']); 
    141      
    142     if (empty($_POST['topPadding'])) 
    143         $_POST['topPadding'] = 0; 
    144     if (empty($_POST['bottomPadding'])) 
    145         $_POST['bottomPadding'] = 0; 
    146     if (empty($_POST['rightPadding'])) 
    147         $_POST['rightPadding'] = 0; 
    148     if (empty($_POST['leftPadding'])) 
    149         $_POST['leftPadding'] = 0; 
    150      
    151     $strNewPadding = "{$_POST['topPadding']}|{$_POST['rightPadding']}|{$_POST['bottomPadding']}|{$_POST['leftPadding']}"; 
    152     $strOldPadding = DBQuery::queryCell("SELECT `value` FROM `{$database['prefix']}UserSettings` WHERE `user` = $owner AND `name` = "); 
    153      
    154     if ($strOldPadding == false || $strNewPadding != $strOldPadding) { 
    155         setUserSetting('thumbnailPadding', $strNewPadding); 
    156         deleteAllThumbnails(ROOT."/cache/thumbnail/$owner"); 
    157     } 
    158 } 
    159  
    160 // 썸네일 여백 색상. 
    161 if (preg_match("/^#?([A-F0-9]{3,6})$/i", $_POST['paddingColor'], $temp)) { 
    162     $strNewColor = $temp[1]; 
    163     $strOldColor = getUserSetting("thumbnailPaddingColor"); 
    164      
    165     if (is_null($strOldColor) || $strNewColor != $strOldColor) { 
    166         setUserSetting('thumbnailPaddingColor', $strNewColor); 
    167         deleteAllThumbnails(ROOT."/cache/thumbnail/$owner"); 
    168     } 
    169 } else { 
    170     $errorArray['paddingColor'] = true; 
    171 } 
    172  
    173 if (count($errorArray) > 0) 
    174     $errorResult['error'] = 1; 
    175 else 
    176     $errorResult['error'] = 0; 
    17723 
    17824$isAjaxRequest ? printRespond($errorResult) : header("Location: ".$_SERVER['HTTP_REFERER']); 
  • sandbox/components/Textcube.Function.Image.php

    r3109 r3370  
    1111    } 
    1212     
    13     function resample($width, $height, $padding=NULL) { 
     13    function resample($width, $height) { 
    1414        if (empty($width) && empty($height)) 
    1515            return false; 
    1616        if (empty($this->imageFile) || !file_exists($this->imageFile)) 
    1717            return false; 
    18          
    19         // validate padding values. 
    20         if (!is_null($padding)) { 
    21             if (!isset($padding['top']) || !is_int($padding['top'])) { 
    22                 $padding['top'] = 0; 
    23             } 
    24             if (!isset($padding['right']) || !is_int($padding['right'])) { 
    25                 $padding['right'] = 0; 
    26             } 
    27             if (!isset($padding['bottom']) || !is_int($padding['bottom'])) { 
    28                 $padding['bottom'] = 0; 
    29             } 
    30             if (!isset($padding['left']) || !is_int($padding['left'])) { 
    31                 $padding['left'] = 0; 
    32             } 
    33         } else { 
    34             $padding['top'] = 0; 
    35             $padding['right'] = 0; 
    36             $padding['bottom'] = 0; 
    37             $padding['left'] = 0; 
    38         } 
    39          
    40         // validate background color. 
    41         if (isset($padding['bgColor'])) { 
    42             if (!eregi("^[0-9A-F]{3,6}$", $padding['bgColor'])) 
    43                 $padding['bgColor'] = "FFFFFF"; 
    44         } else { 
    45             $padding['bgColor'] = "FFFFFF"; 
    46         } 
    47          
    48         // |---------------------------- $width ---------------------------| 
    49         // |-- $padding['left'] --|-- $coreWidth --|-- $padding['right'] --| 
    50         $coreWidth = $width - $padding['left'] - $padding['right']; 
    51         $coreHeight = $height - $padding['top'] - $padding['bottom']; 
    52         if ($coreWidth < 0) 
    53             $coreWidth = 0; 
    54         if ($coreHeight < 0) 
    55             $coreHeight = 0; 
    5618         
    5719        // create an image device as image format. 
     
    9658                break; 
    9759        } 
    98         $originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this); 
     60        // 리샘플링은 최종단계에서 리샘플링만을 하는 기능임. 시스템을 예로 들면 OS의 기능에 해당함. 
     61        // 이미지 프로세스는 어플리케이션의 기능으로 볼 수 있고, 따라서 이미지 리샘플링 중에는 이벤트가 끼어들면 안 됨. 
     62        //$originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this); 
    9963         
    10064        if (Path::getExtension($this->imageFile) == ".gif") { 
     
    10468        } 
    10569         
    106         $bgColorBy16 = $this->hexRGB($padding['bgColor']); 
     70        $bgColorBy16 = $this->hexRGB("FFFFFF"); 
    10771        $temp = imagecolorallocate($this->resultImageDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); 
    10872        imagefilledrectangle($this->resultImageDevice, 0, 0, $width, $height, $temp); 
    109         imagecopyresampled($this->resultImageDevice, $originImageDevice, $padding['left'], $padding['top'], 0, 0, $coreWidth, $coreHeight, imagesx($originImageDevice), imagesy($originImageDevice)); 
     73        imagecopyresampled($this->resultImageDevice, $originImageDevice, 0, 0, 0, 0, $width, $height, imagesx($originImageDevice), imagesy($originImageDevice)); 
    11074        imagedestroy($originImageDevice); 
    111         $this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this); 
     75        //$this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this); 
    11276         
    11377        return true; 
     
    351315    } 
    352316     
    353     function checkExistingThumbnail($originSrc, $thumbnailSrc, $argWidth, $argHeight, $paddingArray=NULL, $waterMarkArray=NULL) { 
    354         if (!file_exists($originSrc)) { 
    355             return 0; 
    356         } 
    357         $originImageInfo = getimagesize($originSrc); 
    358         list($tempWidth, $tempHeight) = Image::calcOptimizedImageSize($originImageInfo[0], $originImageInfo[1], $argWidth, $argHeight); 
    359          
    360         if (!file_exists($thumbnailSrc)) { 
    361             // in the case of a reduced image. 
    362             if ($originImageInfo[0] > $tempWidth || $originImageInfo[1] > $tempHeight) { 
    363                 return 2; 
    364             // even if a original size image or a magnified image, create a thumbnail in the case of existing a watermark file or padding value. 
    365             } else if (($originImageInfo[0] <= $tempWidth || $originImageInfo[1] <= $tempHeight) && (file_exists($waterMarkArray['path']) || !empty($paddingArray))) { 
    366                 return 2; 
    367             } 
    368         } else { 
    369             $thumbnailImageInfo = getimagesize($thumbnailSrc); 
    370             $resizedWidth = $tempWidth; 
    371             $resizedHeight = $tempHeight; 
    372              
    373             // in the case of a reduced image. 
    374             if ($thumbnailImageInfo[0] > $resizedWidth || $thumbnailImageInfo[1] > $resizedHeight) { 
    375                 return 1; 
    376             // no process. 
    377             } else { 
    378                 return 0; 
    379             } 
    380         } 
    381     } 
    382      
    383317    function getImageType($filename) { 
    384318        if (file_exists($filename)) { 
  • sandbox/lib/function/image.php

    r3226 r3370  
    119119 
    120120// img의 width/height에 맞춰 이미지를 리샘플링하는 함수. 썸네일 함수가 아님! 주의. 
     121function resampleImage($imgString, $originSrc, $useAbsolutePath) { 
     122    global $database, $owner, $serviceURL, $pathURL; 
     123     
     124    if (!extension_loaded('gd')) { 
     125        return $imgString; 
     126    } 
     127     
     128    requireComponent('Textcube.Function.Image'); 
     129    if (!is_dir(ROOT."/cache/thumbnail")) { 
     130        @mkdir(ROOT."/cache/thumbnail"); 
     131        @chmod(ROOT."/cache/thumbnail", 0777); 
     132    } 
     133 
     134    if (!is_dir(ROOT."/cache/thumbnail/$owner")) { 
     135        @mkdir(ROOT."/cache/thumbnail/$owner"); 
     136        @chmod(ROOT."/cache/thumbnail/$owner", 0777); 
     137    } 
     138 
     139    $originFileName = basename($originSrc); 
     140 
     141    // 여기로 넘어오는 값은 이미 getAttachmentBinder() 함수에서 고정값으로 변환된 값이므로 % 값은 고려할 필요 없음. 
     142    if (preg_match('/width="([1-9][0-9]*)"/i', $imgString, $temp)) { 
     143        $tempWidth = $temp[1]; 
     144    } 
     145 
     146    if (preg_match('/height="([1-9][0-9]*)"/i', $imgString, $temp)) { 
     147        $tempHeight = $temp[1]; 
     148    } 
     149 
     150    $newTempFileName = preg_replace("/\.([[:alnum:]]+)$/i", ".w{$tempWidth}-h{$tempHeight}.\\1", $originFileName); 
     151    $tempSrc = ROOT."/cache/thumbnail/$owner/".$newTempFileName; 
     152 
     153    $tempURL = $pathURL."/thumbnail/$owner/".$newTempFileName; 
     154    if ($useAbsolutePath == true) { 
     155        $tempURL = "$serviceURL/thumbnail/$owner/$newTempFileName"; 
     156    } 
     157 
     158    if (file_exists($tempSrc)) { 
     159        $imgString = preg_replace('/src="([^"]+)"/i', 'src="'.$tempURL.'"', $imgString); 
     160        $imgString = preg_replace('/width="([^"]+)"/i', 'width="'.$tempWidth.'"', $imgString); 
     161        $imgString = preg_replace('/height="([^"]+)"/i', 'height="'.$tempHeight.'"', $imgString); 
     162        $imgString = preg_replace('/onclick="open_img\(\'([^\']+)\'\)"/', "onclick=\"open_img('$serviceURL/attach/$owner/$originFileName')\"", $imgString); 
     163    } else { 
     164        $AttachedImage = new Image(); 
     165        $AttachedImage->imageFile = $originSrc; 
     166 
     167        // 리샘플링 시작. 
     168        if ($AttachedImage->resample($tempWidth, $tempHeight)) { 
     169            // 리샘플링된 파일 저장. 
     170            $AttachedImage->createThumbnailIntoFile($tempSrc); 
     171            $imgString = preg_replace('/src="([^"]+)"/i', 'src="'.$tempURL.'"', $imgString); 
     172            $imgString = preg_replace('/width="([^"]+)"/i', 'width="'.$tempWidth.'"', $imgString); 
     173            $imgString = preg_replace('/height="([^"]+)"/i', 'height="'.$tempHeight.'"', $imgString); 
     174            $imgString = preg_replace('/onclick="open_img\(\'([^\']+)\'\)"/', "onclick=\"open_img('$serviceURL/attach/$owner/$originFileName')\"", $imgString); 
     175        } 
     176 
     177        unset($AttachedImage); 
     178    } 
     179 
     180    return $imgString; 
     181} 
     182 
    121183function makeThumbnail($imgString, $originSrc, $paddingArray, $waterMarkArray, $useAbsolutePath) { 
    122184    global $database, $owner, $blogURL, $serviceURL, $pathURL; 
  • sandbox/lib/suri.php

    r3294 r3370  
    125125$adminSkinSetting['skin'] = "/style/admin/".getUserSetting("adminSkin", "default"); 
    126126 
     127// 리샘플링 설정값. 
     128$useImageResampling = getUserSetting("resamplingDefault"); 
     129 
    127130// content 본문에 removeAllTags()가 적용되는 것을 방지하기 위한 프로세스를 위한 변수. 
    128131$contentContainer = array(); 
     
    132135else 
    133136    $adminSkinSetting['editorTemplate'] = "/style/default-wysiwyg.css"; 
    134  
    135 // 워터 마크 파일이 있는 곳. 
    136 if (file_exists(ROOT."/attach/$owner/watermark.gif")) { 
    137     $waterMarkPath = ROOT."/attach/$owner/watermark.gif"; 
    138 } else { 
    139     $waterMarkPath = NULL; 
    140 } 
    141  
    142 $waterMarkArray = array(); 
    143 $waterMarkArray['path'] = $waterMarkPath; 
    144 $waterMarkArray['position'] = getWaterMarkPosition(); 
    145 $waterMarkArray['gamma'] = getWaterMarkGamma(); 
    146  
    147 $paddingArray = array(); 
    148 $padding = getThumbnailPadding(); 
    149 $paddingArray['top'] = $padding['top']; 
    150 $paddingArray['right'] = $padding['right']; 
    151 $paddingArray['bottom'] = $padding['bottom']; 
    152 $paddingArray['left'] = $padding['left']; 
    153 $paddingArray['bgColor'] = getThumbnailPaddingColor(); 
    154  
    155 unset($padding); 
    156 unset($waterMarkPath); 
    157137 
    158138if (!file_exists(ROOT . '/config.php')) { 
  • sandbox/lib/view/view.php

    r3369 r3370  
    944944 
    945945function getEntryContentView($owner, $id, $content, $formatter, $keywords = array(), $type = 'Post', $useAbsolutePath = false, $bRssMode = false) { 
    946     global $hostURL, $service, $owner, $waterMarkArray, $paddingArray; 
     946    global $hostURL, $service, $owner, $useImageResampling; 
    947947     
    948948    $content = fireEvent('Format' . $type . 'Content', $content, $id); 
     
    957957     
    958958    // image resampling 
    959     if ($useAbsolutePath == true) { 
    960         preg_match("@<img.+src=['\"]{$hostURL}{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", $view, $images, PREG_SET_ORDER); 
    961         $view = preg_replace("@<img.+src=['\"]{$hostURL}{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", '[#####_#####_#####_image_#####_#####_#####]', $view); 
    962     } else { 
    963         preg_match_all("@<img.+src=['\"]{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", $view, $images, PREG_SET_ORDER); 
    964         $view = preg_replace("@<img.+src=['\"]{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", '[#####_#####_#####_image_#####_#####_#####]', $view); 
    965     } 
     959    if ($useImageResampling == true) { 
     960        if ($useAbsolutePath == true) { 
     961            preg_match("@<img.+src=['\"]{$hostURL}{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", $view, $images, PREG_SET_ORDER); 
     962            $view = preg_replace("@<img.+src=['\"]{$hostURL}{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", '[#####_#####_#####_image_#####_#####_#####]', $view); 
     963        } else { 
     964            preg_match_all("@<img.+src=['\"]{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", $view, $images, PREG_SET_ORDER); 
     965            $view = preg_replace("@<img.+src=['\"]{$service['path']}/attach/{$owner}/(.+)['\"].+/>@Ui", '[#####_#####_#####_image_#####_#####_#####]', $view); 
     966        } 
    966967     
    967     if (count($images) > 0) { 
    968         for ($i=0; $i<count($images); $i++) { 
    969             $view = preg_replace('@\[#####_#####_#####_image_#####_#####_#####\]@', makeThumbnail($images[$i][0], "../attach/{$owner}/{$images[$i][1]}", $paddingArray, $waterMarkArray, $useAbsolutePath), $view, 1); 
     968        if (count($images) > 0) { 
     969            for ($i=0; $i<count($images); $i++) { 
     970                $view = preg_replace('@\[#####_#####_#####_image_#####_#####_#####\]@', resampleImage($images[$i][0], ROOT . "/attach/{$owner}/{$images[$i][1]}", $useAbsolutePath), $view, 1); 
     971            } 
    970972        } 
    971973    } 
    972974     
    973     return $view;; 
     975    return $view; 
    974976} 
    975977 
  • sandbox/plugins/FM_Modern/editor.js

    r3106 r3370  
    608608            getObject(propertyWindowId + "_alt1").value = trim(this.unHtmlspecialchars(this.removeQuot(this.parseAttribute(values[2], "alt")))); 
    609609            getObject(propertyWindowId + "_caption1").value = trim(this.unHtmlspecialchars(this.removeQuot(values[3]))); 
    610             if (this.parseAttribute(values[2], "class").match("tt-resampling")) { 
    611                 getObject(propertyWindowId + "_resample1").checked = true; 
    612             } else if (this.parseAttribute(values[2], "class").match("tt-watermark")) { 
    613                 getObject(propertyWindowId + "_watermark1").checked = true; 
    614                 getObject(propertyWindowId + "_resample1").checked = true; 
    615             } 
    616610 
    617611            this.propertyFilename1 = values[1]; 
     
    655649                getObject(propertyWindowId + "_alt2").value = trim(this.unHtmlspecialchars(this.removeQuot(this.parseAttribute(values[5], "alt")))); 
    656650                getObject(propertyWindowId + "_caption2").value = trim(this.unHtmlspecialchars(this.removeQuot(values[6]))); 
    657                 if (this.parseAttribute(values[5], "class").match("tt-resampling")) { 
    658                     getObject(propertyWindowId + "_resample2").checked = true; 
    659                 } else if (this.parseAttribute(values[5], "class").match("tt-watermark")) { 
    660                     getObject(propertyWindowId + "_watermark2").checked = true; 
    661                     getObject(propertyWindowId + "_resample2").checked = true; 
    662                 } 
    663651            } 
    664652 
     
    670658                getObject(propertyWindowId + "_alt3").value = trim(this.unHtmlspecialchars(this.removeQuot(this.parseAttribute(values[8], "alt")))); 
    671659                getObject(propertyWindowId + "_caption3").value = trim(this.unHtmlspecialchars(this.removeQuot(values[9]))); 
    672                 if (this.parseAttribute(values[8], "class").match("tt-resampling")) { 
    673                     getObject(propertyWindowId + "_resample3").checked = true; 
    674                 } else if (this.parseAttribute(values[8], "class").match("tt-watermark")) { 
    675                     getObject(propertyWindowId + "_watermark3").checked = true; 
    676                     getObject(propertyWindowId + "_resample3").checked = true; 
    677                 } 
    678660            } 
    679661 
     
    22962278    var fixPosition = this.fixPosition, hasGD = this.hasGD; 
    22972279 
    2298     var imagefunc = function (p, q) { 
    2299         if (!hasGD) return ''; 
    2300         return '' + /// 
    2301             '<dl class="resample-property-box line">' + 
    2302                 '<dd>' + 
    2303                     '<input type="checkbox" id="__ID__propertyImage' + p + '_resample' + q + '" onclick="__EDITOR__.checkResampling(\'resample\', ' + p + ', ' + q + '); __EDITOR__.setProperty()" /> <label for="__ID__propertyImage' + p + '_resample' + q + '">' + _t('이미지에 리샘플링을 적용합니다.') + '</label><br />' + 
    2304                     '<input type="checkbox" id="__ID__propertyImage' + p + '_watermark' + q + '" onclick="checkResampling(\'watermark\', ' + p + ', ' + q + '); __EDITOR__.setProperty()" /> <label for="__ID__propertyImage' + p + '_watermark' + q + '">' + _t('이미지에 워터마크를 찍습니다.') + '</label>' + 
    2305                 '</dd>' + 
    2306             '</dl>'; 
    2307     } 
    2308  
    23092280    // hyperlink 
    23102281    var html = //// 
     
    23952366                    '<dd><textarea class="input-text" id="__ID__propertyImage1_caption1" onkeyup="__EDITOR__.setProperty()" onkeypress="return preventEnter(event);"></textarea></dd>' + 
    23962367                '</dl>' + 
    2397                 imagefunc(1, 1) + 
    23982368            '</div>' + 
    23992369        '</div>'; 
     
    24212391                    '<dd><textarea class="input-text" id="__ID__propertyImage2_caption1" onkeyup="__EDITOR__.setProperty()" onkeypress="return preventEnter(event);"></textarea></dd>' + 
    24222392                '</dl>' + 
    2423                 imagefunc(2, 1) + 
    24242393            '</div>' + 
    24252394            '<div class="group">' + 
     
    24372406                    '<dd><textarea class="input-text" id="__ID__propertyImage2_caption2" onkeyup="__EDITOR__.setProperty()" onkeypress="return preventEnter(event);"></textarea></dd>' + 
    24382407                '</dl>' + 
    2439                 imagefunc(2, 2) + 
    24402408            '</div>' + 
    24412409        '</div>'; 
     
    24632431                    '<dd><textarea class="input-text" id="__ID__propertyImage3_caption1" onkeyup="__EDITOR__.setProperty()" onkeypress="return preventEnter(event);"></textarea></dd>' + 
    24642432                '</dl>' + 
    2465                 imagefunc(3, 1) + 
    24662433            '</div>' + 
    24672434            '<div class="group">' + 
     
    24792446                    '<dd><textarea class="input-text" id="__ID__propertyImage3_caption2" onkeyup="__EDITOR__.setProperty()" onkeypress="return preventEnter(event);"></textarea></dd>' + 
    24802447                '</dl>' + 
    2481                 imagefunc(3, 2) + 
    24822448            '</div>' + 
    24832449            '<div class="group">' + 
     
    24952461                    '<dd><textarea class="input-text" id="__ID__propertyImage3_caption3" onkeyup="__EDITOR__.setProperty()" onkeypress="return preventEnter(event);"></textarea></dd>' + 
    24962462                '</dl>' + 
    2497                 imagefunc(3, 3) + 
    24982463            '</div>' + 
    24992464        '</div>';