최근글(갤러리) 질문드립니다. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

최근글(갤러리) 질문드립니다. 정보

최근글(갤러리) 질문드립니다.

본문

최근글 갤러리를 사용중인데요..

게시판 리스트상이나 어디나 다 잘나오는 사진이..

최근글에는 x로 깨져있습니다..

다른 최근글 갤러리를 사용하면 또 잘나오구요..

근데 다른걸로 교체할수가 없어서..

어디가 잘못되었는지 확인좀 부탁드려도 될까요..

사이트 주소는 www.cozyworld.co.kr 이구요..

아래 최근글 소스입니다..

============================================================================================
<?php
if (!defined("_GNUBOARD_")) exit; //개별 페이지 접근 불가
include_once("$g4[path]/lib/thumb.lib.php");

$set_value = explode("/",$options);
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
$thumb_width = $set_value[0]; //썸네일 가로 크기
$thumb_height = $set_value[1]; //썸네일 세로 크기
$thumb_quality = "90"; //썸네일 이미지 품질
$g3_width = ($thumb_width + 10) * $set_value[2]; //전체 가로 크기
$filter[type] = "99";
$filter[arg1] = "100";
$filter[arg2] = "1";
$filter[arg3] = "2";
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>

<style type="text/css">
.g3_<?php echo $bo_table ?> {clear:both; position:relative; width:<?php echo $g3_width + 10 ?>px; text-align:right}
.g3_<?php echo $bo_table ?> .g3_title {height:16px; text-align:left; background:url(<?php echo $latest_skin_path ?>/img/line.gif) repeat-x 0 4px}
.g3_<?php echo $bo_table ?> .g3_title a:link, .g3_title a:visited, .g3_title a:active {background-color:#fff; padding-right:8px; text-decoration:none; font:bold 12px gulim, tahoma; color:#555}
.g3_<?php echo $bo_table ?> .g3_title a:hover {color:#000}
.g3_<?php echo $bo_table ?> .g3_thumb {margin-left:10px; width:<?php echo $g3_width ?>px; text-align:left}
.g3_<?php echo $bo_table ?> .g3_thumb ul {clear:both; list-style:none; margin:0; padding:0}
.g3_<?php echo $bo_table ?> .g3_thumb ul li {float:left; margin:10px 0 5px; width:<?php echo $thumb_width + 10 ?>px}
.g3_<?php echo $bo_table ?> .g3_thumb ul li .thumb_front .g3_new {position:absolute; width:27px; height:10px; background:url(<?php echo $latest_skin_path ?>/img/icon_new.gif) no-repeat 3px 3px; overflow:hidden}
.g3_<?php echo $bo_table ?> .g3_thumb ul li .thumb_front {position:absolute; width:<?php echo $thumb_width ?>px; height:<?php echo $thumb_height ?>px; overflow:hidden; cursor:pointer; z-index:10}
.g3_<?php echo $bo_table ?> .g3_thumb ul li .thumb_back {position:absolute; width:<?php echo $thumb_width ?>px; height:<?php echo $thumb_height ?>px; overflow:hidden; cursor:pointer; z-index:-1}
.g3_<?php echo $bo_table ?> .g3_thumb ul li .thumb_subject {padding-top:<?php echo $thumb_height + 5 ?>px; width:<?php echo $thumb_width ?>px; overflow:hidden}
.g3_<?php echo $bo_table ?> .g3_thumb ul li .thumb_subject a:link, .thumb_subject a:visited, .thumb_subject a:active {text-decoration:none; font:normal 11px dotum, tahoma; color:#777; letter-spacing:-1px; white-space:nowrap}
.g3_<?php echo $bo_table ?> .g3_thumb ul li .thumb_subject a:hover {color:#000}
.g3_<?php echo $bo_table ?> .g3_no_list {padding-top:10px; height:<?php echo $thumb_height ?>px; text-align:center; font-size:12px; color:#777}
</style>

<div class="g3_<?php echo $bo_table ?>">

<div class="g3_thumb">
  <?php if (!count($list) == 0) { ?>
  <ul>
    <?php
    for ($i = 0; $i < count($list); $i++) {
      $noimg = $latest_skin_path."/img/_noimg.gif";
      $thumb = $thumb_path.'/'.$list[$i][wr_id];
      $file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];

      if ($list[$i][wr_id]) {
        $thumb = thumbnail($file, $thumb_width, $thumb_height, 0, 1, $thumb_quality, 0, "",  $filter, $noimg);
      }
      if ($edit_img = $list[$i]['wr_content']) {
        if (eregi("data/cheditor4[^<>]*\.(gif|jp[e]?g|jpg|png|bmp)", $edit_img, $tmp)) {
          $file = $g4[path].'/' . $tmp[0]; // 파일명
          $thumb = thumbnail($file, $thumb_width, $thumb_height, 0, 1, $thumb_quality, 0, "",  $filter, $noimg);
      }
    }       
    ?>
    <li>
      <div class="thumb_front">
        <a href="<?php echo $list[$i][href] ?>"><img src="<?php echo $thumb ?>" width="<?php echo $thumb_width ?>" height="<?php echo $thumb_height ?>" border="0" alt="" onmouseover="this.src='<?php echo $latest_skin_path ?>/img/thumb_over.png'" onmouseout="this.src='<?php echo $thumb ?>'"></a>
      </div>
      <div class="thumb_back"><img src="<?php echo $thumb ?>" width="<?php echo $thumb_width ?>" height="<?php echo $thumb_height ?>" alt="" title=""></div>
  <center>
  <div class="thumb_subject"><a href="<?php echo $list[$i][href] ?>"><?php echo $list[$i][subject] ?></a></div>

  <a href="<?php echo $list[$i][href] ?>"><?php echo $list[$i][wr_4] ?></a>
  <br>
<? if($list[$i][wr_1] == "1")  { echo "<img src='{$latest_skin_path}/img/icon_recommend.jpg' border='0'  align='absmiddle'>"; } ?>
<? if($list[$i][wr_2] == "1") { echo "<img src='{$latest_skin_path}/img/icon_hit.jpg' border='0'  align='absmiddle'>"; } ?>
<? if($list[$i][wr_3] == "1")  { echo "<img src='{$latest_skin_path}/img/icon_new.jpg' border='0'  align='absmiddle'>"; } ?>
  </center>

    </li>
    <?php } ?>
  </ul>
  <?php } else { ?>
  <div class="g3_no_list">게시물이 없습니다.</div>
  <?php } ?>
</div>
</div>
============================================================================================
  • 복사

댓글 전체

리스트에서는 잘 나오는 것은 썸네일을 불러오지않고 원본 이미지를 불러오기 때문에 정상적으로 나옵니다
최신글 리스트에서는 썸네일 생성함수 -- lib/thumb.lib.php 에서 thumbnail() 에서
썸네일 저장할 디릭토리를 만드는 부분을 확인해보아야겠군요

위쪽에서
$thumb_path = $data_path.'/thumb';
@mkdir($thumb_path, 0707);
이렇게 되어있고
실제 썸네일은 /data/file/product/_thumb/170x150_90/썸네일 이렇게 불러오는군요

$thumb_path = $data_path.'/_thumb/170x150_90';<---이렇게 해보고 안되면
썸네일 생성 함수도 보아야 진단 가능하겠습니다
답변 감사드립니다.

말씀해주신데로 소스변경해도 똑같이 나오는데..

그럼 최신글에서 썸네일 불러오지 않고 원본이미지를 불러올수는 없을까요?

thumb.lib.php 에서 소스를 봐도... 알수가 없습니다;ㅠ

처음엔 잘 나왔었는데... 어디를 잘못만져서 안나오는지를 모르겠네요..
말씀하신대로..

$thumb_path = $data_path.'/thumb';

를..

$thumb_path = $data_path.'/_thumb/170x150_90';

로 변경했구요..

불당썸은 bbs/_thumb/thumb.lib.php 에 저장되어 있습니다.

소스는..

===================================================================================
<?
// 원본 이미지를 넘기면 비율에 따라 썸네일 이미지를 생성함
// 가로, 세로, 파일경로, 생성경로, true
function createThumb($imgWidth, $imgHeight, $imgSource, $imgThumb='', $iscut=false)
{
    if (!$imgThumb)
        $imgThumb = $imgSource;

    $size = getimagesize($imgSource);

    if ($size[2] == 1)
        $source = imagecreatefromgif($imgSource);
    else if ($size[2] == 2)
        $source = imagecreatefromjpeg($imgSource);
    else if ($size[2] == 3)
        $source = imagecreatefrompng($imgSource);
    else
        continue;

    $rate = $imgWidth / $size[0];
    $height = (int)($size[1] * $rate);

    if ($height < $imgHeight) {

        $target = @imagecreatetruecolor($imgWidth, $height);

    } else {

        $target = @imagecreatetruecolor($imgWidth, $imgHeight);

    }

    @imagecopyresampled($target, $source, 0, 0, 0, 0, $imgWidth, $height, $size[0], $size[1]);
    @imagejpeg($target, $imgThumb, 100);
    @chmod($imgThumb, 0606); // 추후 삭제를 위하여 파일모드 변경
}

// 프로그램 : 불당썸 2.0.x
// 개 발 자 : 아빠불당 (http://www.kingsquare.nl/phppsdreader
*
*    TODO
*    ----
*    - read color values for "multichannel data" PSD files
*    - find and implement (hunter)lab to RGB algorithm
*    - fix 32 bit colors... has something to do with gamma and exposure available since CS2, but dunno how to read them...
*/


class PhpPsdReader {
    var $infoArray;
    var $fp;
    var $fileName;
    var $tempFileName;
    var $colorBytesLength;

    function PhpPsdReader($fileName) {
        set_time_limit(0);
        $this->infoArray = array();
        $this->fileName = $fileName;
        $this->fp = fopen($this->fileName,'r');

        if (fread($this->fp,4)=='8BPS') {
            $this->infoArray['version id'] = $this->_getInteger(2);
            fseek($this->fp,6,SEEK_CUR); // 6 bytes of 0's
            $this->infoArray['channels'] = $this->_getInteger(2);
            $this->infoArray['rows'] = $this->_getInteger(4);
            $this->infoArray['columns'] = $this->_getInteger(4);
            $this->infoArray['colorDepth'] = $this->_getInteger(2);
            $this->infoArray['colorMode'] = $this->_getInteger(2);


            /* COLOR MODE DATA SECTION */ //4bytes Length The length of the following color data.
            $this->infoArray['colorModeDataSectionLength'] = $this->_getInteger(4);
            fseek($this->fp,$this->infoArray['colorModeDataSectionLength'],SEEK_CUR); // ignore this snizzle

            /*  IMAGE RESOURCES */
            $this->infoArray['imageResourcesSectionLength'] = $this->_getInteger(4);
            fseek($this->fp,$this->infoArray['imageResourcesSectionLength'],SEEK_CUR); // ignore this snizzle

            /*  LAYER AND MASK */
            $this->infoArray['layerMaskDataSectionLength'] = $this->_getInteger(4);
            fseek($this->fp,$this->infoArray['layerMaskDataSectionLength'],SEEK_CUR); // ignore this snizzle


            /*  IMAGE DATA */
            $this->infoArray['compressionType'] = $this->_getInteger(2);
            $this->infoArray['oneColorChannelPixelBytes'] = $this->infoArray['colorDepth']/8;
            $this->colorBytesLength = $this->infoArray['rows']*$this->infoArray['columns']*$this->infoArray['oneColorChannelPixelBytes'];

            if ($this->infoArray['colorMode']==2) {
                $this->infoArray['error'] = 'images with indexed colours are not supported yet';
                return false;
            }
        } else {
            $this->infoArray['error'] = 'invalid or unsupported psd';
            return false;
        }
    }


    function getImage() {
        // decompress image data if required
        switch($this->infoArray['compressionType']) {
            // case 2:, case 3: zip not supported yet..
            case 1:
                // packed bits
                $this->infoArray['scanLinesByteCounts'] = array();
                for ($i=0; $i<($this->infoArray['rows']*$this->infoArray['channels']); $i++) $this->infoArray['scanLinesByteCounts'][] = $this->_getInteger(2);
                $this->tempFileName = tempnam(realpath('/tmp'),'decompressedImageData');
                $tfp = fopen($this->tempFileName,'wb');
                foreach ($this->infoArray['scanLinesByteCounts'] as $scanLinesByteCount) {
                    fwrite($tfp,$this->_getPackedBitsDecoded(fread($this->fp,$scanLinesByteCount)));
                }
                fclose($tfp);
                fclose($this->fp);
                $this->fp = fopen($this->tempFileName,'r');
            default:
                // continue with current file handle;
                break;
        }

        // let's write pixel by pixel....
        $image = imagecreatetruecolor($this->infoArray['columns'],$this->infoArray['rows']);

        for ($rowPointer = 0; ($rowPointer < $this->infoArray['rows']); $rowPointer++) {
            for ($columnPointer = 0; ($columnPointer < $this->infoArray['columns']); $columnPointer++) {
                /*    The color mode of the file. Supported values are: Bitmap=0;
                    Grayscale=1; Indexed=2; RGB=3; CMYK=4; Multichannel=7;
                    Duotone=8; Lab=9.
                */
                switch ($this->infoArray['colorMode']) {
                    case 2: // indexed... info should be able to extract from color mode data section. not implemented yet, so is grayscale
                        exit;
                        break;
                    case 0:
                        // bit by bit
                        if ($columnPointer == 0) $bitPointer = 0;
                        if ($bitPointer==0) $currentByteBits = str_pad(base_convert(bin2hex(fread($this->fp,1)), 16, 2),8,'0',STR_PAD_LEFT);
                        $r = $g = $b = (($currentByteBits[$bitPointer]=='1')?0:255);
                        $bitPointer++;
                        if ($bitPointer==8) $bitPointer = 0;
                        break;

                    case 1:
                    case 8: // 8 is indexed with 1 color..., so grayscale
                        $r = $g = $b = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        break;

                    case 4: // CMYK
                        $c = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        $currentPointerPos = ftell($this->fp);
                        fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                        $m = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                        $y = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                        $k = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        fseek($this->fp,$currentPointerPos);
                        $r = round(($c * $k) / (pow(2,$this->infoArray['colorDepth'])-1));
                        $g = round(($m * $k) / (pow(2,$this->infoArray['colorDepth'])-1));
                        $b = round(($y * $k) / (pow(2,$this->infoArray['colorDepth'])-1));

                          break;

                          case 9: // hunter Lab
                              // i still need an understandable lab2rgb convert algorithm... if you have one, please let me know!
                            $l = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                            $currentPointerPos = ftell($this->fp);
                            fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                            $a = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                            fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                            $b =  $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                            fseek($this->fp,$currentPointerPos);

                            $r = $l;
                            $g = $a;
                            $b = $b;

                        break;
                    default:
                        $r = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        $currentPointerPos = ftell($this->fp);
                        fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                        $g = $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        fseek($this->fp,$this->colorBytesLength-1,SEEK_CUR);
                        $b =  $this->_getInteger($this->infoArray['oneColorChannelPixelBytes']);
                        fseek($this->fp,$currentPointerPos);
                        break;

                }

                if (($this->infoArray['oneColorChannelPixelBytes']==2)) {
                    $r = $r >> 8;
                    $g = $g >> 8;
                    $b = $b >> 8;
                } elseif (($this->infoArray['oneColorChannelPixelBytes']==4)) {
                    $r = $r >> 24;
                    $g = $g >> 24;
                    $b = $b >> 24;
                }

                $pixelColor = imagecolorallocate($image,$r,$g,$b);
                imagesetpixel($image,$columnPointer,$rowPointer,$pixelColor);
            }
        }
        fclose($this->fp);
        if (isset($this->tempFileName)) unlink($this->tempFileName);
        return $image;
    }

    /**
    *
    * PRIVATE FUNCTIONS
    *
    */

    function _getPackedBitsDecoded($string) {
        /*
        The PackBits algorithm will precede a block of data with a one byte header n, where n is interpreted as follows:
        n Meaning
        0 to 127 Copy the next n + 1 symbols verbatim
        -127 to -1 Repeat the next symbol 1 - n times
        -128 Do nothing

        Decoding:
        Step 1. Read the block header (n).
        Step 2. If the header is an EOF exit.
        Step 3. If n is non-negative, copy the next n + 1 symbols to the output stream and go to step 1.
        Step 4. If n is negative, write 1 - n copies of the next symbol to the output stream and go to step 1.

        */

        $stringPointer = 0;
        $returnString = '';

        while (1) {
            if (isset($string[$stringPointer])) $headerByteValue = $this->_unsignedToSigned(hexdec(bin2hex($string[$stringPointer])),1);
            else return $returnString;
            $stringPointer++;

            if ($headerByteValue >= 0) {
                for ($i=0; $i <= $headerByteValue; $i++) {
                    $returnString .= $string[$stringPointer];
                    $stringPointer++;
                }
            } else {
                if ($headerByteValue != -128) {
                    $copyByte = $string[$stringPointer];
                    $stringPointer++;

                    for ($i=0; $i < (1-$headerByteValue); $i++) {
                        $returnString .= $copyByte;
                    }
                }
            }
        }
    }

    function _unsignedToSigned($int,$byteSize=1) {
        switch($byteSize) {
            case 1:
                if ($int<128) return $int;
                else return -256+$int;
                break;

            case 2:
                if ($int<32768) return $int;
                else return -65536+$int;

            case 4:
                if ($int<2147483648) return $int;
                else return -4294967296+$int;

            default:
                return $int;
        }
    }

    function _hexReverse($hex) {
        $output = '';
        if (strlen($hex)%2) return false;
        for ($pointer = strlen($hex);$pointer>=0;$pointer-=2) $output .= substr($hex,$pointer,2);
        return $output;
    }

    function _getInteger($byteCount=1) {
        switch ($byteCount) {
            case 4:
                // for some strange reason this is still broken...
                return @reset(unpack('N',fread($this->fp,4)));
                break;

            case 2:
                return @reset(unpack('n',fread($this->fp,2)));
                break;

            default:
                return hexdec($this->_hexReverse(bin2hex(fread($this->fp,$byteCount))));
        }
    }
}

/**
 * Returns an image identifier representing the image obtained from the given filename, using only GD, returns an empty string on failure
 *
 * @param string $fileName
 * @return image identifier
 */

function imagecreatefrompsd($fileName) {
    $psdReader = new PhpPsdReader($fileName);
    if (isset($psdReader->infoArray['error'])) return '';
    else return $psdReader->getImage();
}
?>

===================================================================================

입니다..
어이쿠 이렇게 긴 소스화일은 첨부화일로 올리면 좋을텐데요
스킨 상단에 보면
include_once("$g4[path]/lib/thumb.lib.php"); <---이렇게 썸네일 만드는 화일을 불러오고 있는데
bbs/_thumb/thumb.lib.php <--이 불당썸은 어디서 include 하는 곳이 있나요?
위 두 화일이 같은 내용인가요?

/data/file/product/_thumb/170x150_90 폴더에 썸네일로 생성된 화일들이 있는지 보세요
생성된 화일들이 없다면 왜 생성되지않는지 찾아야 하니 머리 아플테고
원본이미지 사이즈가 크지않은 것 같으니 목록처럼 그냥 원본을 불러와도 되겠습니다

<img src="<?php echo $thumb ?>" <--- 이 부분을 수정 하면 됩니다
수정 후
<img src="<?php echo $file ?>"

include_once("$g4[path]/lib/thumb.lib.php"); <-- 이 부분 삭제해버리세요

$thumb = thumbnail(~~~)<-- 이 부분 삭제해버리세요
답변 주셨는데... 너무 늦게 봤네요..

라섹 수술을 하느라..

정말 감사합니다. 말씀해주신데로 $thumb 를 $file로 대체하고 이제 문제없이 잘 나오게 되었습니다.ㅠㅠ

정말 감사드려요^^
© SIRSOFT
현재 페이지 제일 처음으로