배추빌더 썸네일 크롭 질문입니다.

· 2012-04-12 (목) 12:36:59 · 1658
// 썸네일 생성.. 080408, curlychoi
function mw_make_thumbnail($set_width, $set_height, $source_file, $thumbnail_file='', $keep=false)
{
global $mw_basic;

if (!$thumbnail_file)
$source_file = $thumbnail_file;

$size = @getimagesize($source_file);

switch ($size[2]) {
case 1: $source = @imagecreatefromgif($source_file); break;
case 2: $source = @imagecreatefromjpeg($source_file); break;
case 3: $source = @imagecreatefrompng($source_file); break;
default: return false;
}

if ($keep)
{
$keep_size = mw_thumbnail_keep($size, $set_width, $set_height);
$set_width = $get_width = $keep_size[0];
$set_height = $get_height = $keep_size[1];
}
else
{
$rate = $set_width / $size[0];
$get_width = $set_width;
$get_height = (int)($size[1] * $rate);

if ($get_height < $set_height) {
//$get_width = $set_width + $set_height - $get_height;
//$get_height = $set_height;
$rate = $set_height / $size[1];
$get_height = $set_height;
$get_width = (int)($size[0] * $rate);
}
}

$target = @imagecreatetruecolor($set_width, $set_height);
$white = @imagecolorallocate($target, 255, 255, 255);
@imagefilledrectangle($target, 0, 0, $set_width, $set_height, $white);
@imagecopyresampled($target, $source, 0, 0, 0, 0, $get_width, $get_height, $size[0], $size[1]);

if ($mw_basic[cf_watermark_use_thumb] && file_exists($mw_basic[cf_watermark_path])) { // watermark
mw_watermark($target, $set_width, $set_height
, $mw_basic[cf_watermark_path]
, $mw_basic[cf_watermark_position]
, $mw_basic[cf_watermark_transparency]);
}

@imagejpeg($target, $thumbnail_file, 100);
@chmod($thumbnail_file, 0606);

@imagedestroy($target);
@imagedestroy($source);
}


이게 기본적은 썸네일 생성 합수인것 같은데요..

여기에 썸네일을 중간 기준으로 crop 을 할려면 어떻게 수정을 해야하는지 도움좀 주세요~
|
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

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

+
제목 글쓴이 날짜 조회
12-04-12 조회 5,235
12-04-12 조회 3,368
12-04-12 조회 1,257
12-04-12 조회 1,696
12-04-12 조회 1,717
12-04-12 조회 1,627
12-04-12 조회 1,825
12-04-12 조회 1,623
12-04-12 조회 1,659
12-04-12 조회 2,336
12-04-12 조회 1,099
12-04-12 조회 1,043
12-04-12 조회 1,766
12-04-12 조회 1,390
12-04-12 조회 1,097
12-04-12 조회 1,006
12-04-12 조회 1,029
12-04-12 조회 1,070
12-04-12 조회 2,045
12-04-12 조회 1,051