현장 확인 업로드
This commit is contained in:
@@ -49,7 +49,6 @@ class Common
|
||||
$wmTextAlpha = 0.5; // 워터마크 텍스트 투명도
|
||||
|
||||
try {
|
||||
|
||||
$img = new \Imagick();
|
||||
if (is_string($imagePath) && is_file($imagePath)) {
|
||||
$img->readImage($imagePath);
|
||||
@@ -96,19 +95,23 @@ class Common
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($wmImagePath))
|
||||
if (empty($wmImagePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 워터마크 이미지 경로 처리
|
||||
if (substr($wmImagePath, 0, 1) == '/') {
|
||||
$wmImagePath = substr($wmImagePath, 1);
|
||||
}
|
||||
|
||||
// ROOTPATH와 결합하여 절대 경로 생성 (img 폴더는 프로젝트 루트에 있음)
|
||||
$fullWmPath = ROOTPATH . $wmImagePath;
|
||||
|
||||
if (!is_file($fullWmPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// echo FCPATH.$wmImagePath;
|
||||
|
||||
|
||||
|
||||
$wm = new \Imagick($wmImagePath);
|
||||
$wm = new \Imagick($fullWmPath);
|
||||
$hWm = $wm->getImageHeight();
|
||||
$wWm = $wm->getImageWidth();
|
||||
|
||||
@@ -119,29 +122,34 @@ class Common
|
||||
$img->compositeImage($wm, \Imagick::COMPOSITE_OVER, $wmImgLeft, $wmImgTop);
|
||||
$wm->destroy();
|
||||
|
||||
$draw = new \ImagickDraw();
|
||||
// 워터마크 텍스트가 있는 경우에만 텍스트 그리기
|
||||
if (!empty($wmText)) {
|
||||
$draw = new \ImagickDraw();
|
||||
|
||||
$basePath = defined('BASEPATH') ? BASEPATH : (defined('ROOTPATH') ? ROOTPATH . 'system/' : '');
|
||||
$wmFont = $basePath . 'fonts/' . $wmFont;
|
||||
if (is_file($wmFont)) {
|
||||
$draw->setFont($wmFont);
|
||||
// 폰트 경로: img/watermark/fonts/
|
||||
if (!empty($wmFont)) {
|
||||
$fontPath = ROOTPATH . 'img/watermark/fonts/' . $wmFont;
|
||||
if (is_file($fontPath)) {
|
||||
$draw->setFont($fontPath);
|
||||
}
|
||||
}
|
||||
|
||||
$draw->setFontSize($wmFontSize);
|
||||
$draw->setFillColor(new \ImagickPixel($wmTextColor));
|
||||
// $draw->setFillAlpha( $wmTextAlpha );
|
||||
$draw->setFillOpacity($wmTextAlpha); // 워터마크 텍스트 투명도 설정
|
||||
$draw->setTextAlignment(2); // center
|
||||
$draw->setStrokeAntialias(1);
|
||||
$draw->setStrokeWidth(1);
|
||||
$draw->setStrokeColor(new \ImagickPixel('#000000'));
|
||||
// $draw->setStrokeAlpha(0.1);
|
||||
$draw->setStrokeOpacity(0.1);
|
||||
$draw->annotation($wImg / 2, $wmTxtTop, $wmText);
|
||||
|
||||
$img->drawImage($draw);
|
||||
$draw->destroy();
|
||||
}
|
||||
|
||||
$draw->setFontSize($wmFontSize);
|
||||
$draw->setFillColor(new \ImagickPixel($wmTextColor));
|
||||
// $draw->setFillAlpha( $wmTextAlpha );
|
||||
$draw->setFillOpacity($wmTextAlpha); // 워터마크 텍스트 투명도 설정
|
||||
$draw->setTextAlignment(2); // center
|
||||
$draw->setStrokeAntialias(1);
|
||||
$draw->setStrokeWidth(1);
|
||||
$draw->setStrokeColor(new \ImagickPixel('#000000'));
|
||||
// $draw->setStrokeAlpha(0.1);
|
||||
$draw->setStrokeOpacity(0.1);
|
||||
$draw->annotation($wImg / 2, $wmTxtTop, $wmText);
|
||||
|
||||
$img->drawImage($draw);
|
||||
$draw->destroy();
|
||||
|
||||
// $img->writeImage();
|
||||
|
||||
$watermark_img = $img->getImageBlob();
|
||||
@@ -149,14 +157,9 @@ class Common
|
||||
if (empty($key)) {
|
||||
throw new \RuntimeException('Empty upload key');
|
||||
}
|
||||
|
||||
$ok = $uploader->upload_object_storage_imagick2($key, $watermark_img);
|
||||
if ($ok) {
|
||||
log_message('info', '[watermarking] upload success key={key} size={size} cpid={cpid}', [
|
||||
'key' => $key,
|
||||
'size' => strlen($watermark_img),
|
||||
'cpid' => $cpid,
|
||||
]);
|
||||
} else {
|
||||
if (!$ok) {
|
||||
log_message('error', '[watermarking] upload failed key={key} cpid={cpid}', [
|
||||
'key' => $key,
|
||||
'cpid' => $cpid,
|
||||
@@ -166,7 +169,11 @@ class Common
|
||||
|
||||
// $object_upload = $this->upload->upload_object_storage($imagePath , $imagePath , 'data');
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', '[watermarking] ' . $e->getMessage());
|
||||
log_message('error', '[watermarking] Exception: {message} at {file}:{line}', [
|
||||
'message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user