회원사진에서 레터박스 색상 추가하는 방법좀 알려주세요 ㅠㅠ

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
회원사진에서 레터박스 색상 추가하는 방법좀 알려주세요 ㅠㅠ

QA

회원사진에서 레터박스 색상 추가하는 방법좀 알려주세요 ㅠㅠ

본문


<?php
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 시작
//----------------------------------------------------------
$mb_profile_img = '';
if (isset($_FILES['mb_profile_img']) && is_uploaded_file($_FILES['mb_profile_img']['tmp_name'])) {
	$mb_profile_img_ext = array_pop(explode(".", strtolower($_FILES['mb_profile_img']['name'])));

	if(@ereg($mb_profile_img_ext, "gif|jpg|jpeg|png")) {
        // 아이콘 용량이 1 MB 이하만 업로드 가능 (용량을 조정하고 싶으면 아래 수치 조정)
        if ($_FILES['mb_profile_img']['size'] <= (1 * 1024 * 1024)) {

            $dest_path_raw = G5_DATA_PATH."/member/profile_img/".$mb_id."_raw.".$mb_profile_img_ext;
            move_uploaded_file($_FILES['mb_profile_img']['tmp_name'], $dest_path_raw);
            $dest_path = G5_DATA_PATH."/member/profile_img/".$mb_id.".jpg";

			$size = getimagesize($dest_path_raw);
			if ($size[2] == 1 || $size[2] == 2 || $size[2] == 3) { // 이미지 파일이 진짜인지 판별
				if($size[0] < 60 || $size[1] < 60) { // 이미지 사이즈가 너무 작을 경우
					$msg .= '이미지 크기가 너무 작습니다. 가로세로 60픽셀 이상의 이미지를 올려주세요.';
				} else {
					if(file_exists($dest_path)) { // 이미 파일이 있을 경우(즉 수정일 경우) 먼저 파일을 삭제
						@unlink($dest_path);
					}

					// 이미지 불러와서 판 깔기(...)
					if($size[2] == 2) {
						$image_call = imagecreatefromjpeg($dest_path_raw);
					} elseif($size[2] == 1) {
						$image_call = imagecreatefromgif($dest_path_raw);
					} elseif($size[2] == 3) {
						$image_call = imagecreatefrompng($dest_path_raw);
					}

					// 업로드된 이미지 시작점 및 크기 설정 (크롭)
					// 기본값들
					$basic_img_w = 60;
					$basic_img_h = 60;
					$src_img_x = 0;
					$src_img_y = 0;
					$src_img_w = $size[0];
					$src_img_h = $size[1];
					$des_img_x = 0;
					$des_img_y = 0;
					$des_img_w = $basic_img_w;
					$des_img_h = $basic_img_h; 
					if($size[0] > $size[1]) { // 가로가 길 경우
						$src_img_w = $size[1];
						switch($mb_profile_img_crop) {
							case 1:
								break;
							case 2:
								$src_img_x = $size[0] - $size[1];
								break;
							case 3:
								$src_img_x = (int)(($size[0] - $size[1]) / 2);
								break;
							case 4:
								$src_img_w = $size[0];
								$des_img_h = (int)($basic_img_w * ($size[1] / $size[0]));
								$des_img_y = (int)(($basic_img_h - $des_img_h) / 2);
								break;
						}
					} elseif($size[0] < $size[1]) { // 세로가 길 경우
						$src_img_h = $size[0];
						switch($mb_profile_img_crop) {
							case 1:
								break;
							case 2:
								$src_img_y = $size[1] - $size[0];
								break;
							case 3:
								$src_img_x = (int)(($size[1] - $size[0]) / 2);
								break;
							case 4:
								$src_img_h = $size[1];
								$des_img_w = (int)($basic_img_h * ($size[0] / $size[1]));
								$des_img_x = (int)(($basic_img_w - $des_img_w) / 2);
								break;
						}
					}

					// 트루컬러 이미지 캔버스 준비
					$image_canvas = imagecreatetruecolor($basic_img_w,$basic_img_h);

					// 이미지 리사이즈
					imagecopyresampled($image_canvas, $image_call, $des_img_x, $des_img_y, $src_img_x, $src_img_y, $des_img_w, $des_img_h, $src_img_w, $src_img_h);

					// 이미지 저장
					imagejpeg($image_canvas, $dest_path, 80);

					// 메모리에서 작업내용 삭제
					imagedestroy($image_call);
					imagedestroy($image_canvas);

					// 원본 이미지 삭제
					@unlink($dest_path_raw);
				}

            } else {	// gif,jpg,png 파일이 아니면 올라간 이미지를 삭제한다.
				@unlink($dest_path_raw);
			}
        } else {
            $msg .= '프로필 이미지를 1 MB 이하로 업로드 해주십시오.';
        }

    } else {
        $msg .= $_FILES['$mb_profile_img']['name'].'은(는) 이미지 파일이 아닙니다.';
    }
} 

if($mb_profile_img_del == 1) { // 파일 삭제에 체크가 들어온 경우
	$dest_path = G5_DATA_PATH."/member/profile_img/".$mb_id.".jpg";
	@unlink($dest_path);
}
//----------------------------------------------------------
// 프로필 이미지 파일 업로드 끝
//----------------------------------------------------------

이런식으로 구성해서 회원사진기능을 추가했는데 여기서 썸네일.lib말고 따로 함수를 추가해서
$image_canvas 의배경색(레터박스)의 색상이 빠져있어서 검정색으로 나오더라구요..ㅠㅠ
어떻게 추가해야할지 잘모르겠어요 ㅠㅠ
도움주시면 정말 감사하겠습니다..

이 질문에 댓글 쓰기 :

답변을 작성하시기 전에 로그인 해주세요.
전체 60,046
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT