현장 확인 업로드
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(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class MyUpload
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 업로드 요청
|
||||
* 파일 업로드 요청 (Object Storage 전용)
|
||||
* 추가일 2025.12.24
|
||||
* 작성자 - yangsh
|
||||
*/
|
||||
@@ -73,39 +73,40 @@ class MyUpload
|
||||
|
||||
$newName = $file->getRandomName();
|
||||
|
||||
// ✅ PHP 임시 업로드 파일 경로 (writable로 move() 필요 없음)
|
||||
// ✅ PHP 임시 업로드 파일 경로
|
||||
$tmpFile = $file->getTempName();
|
||||
if (!is_file($tmpFile)) {
|
||||
$this->set_error('upload_temp_file_missing');
|
||||
log_message('error', 'do_upload2 temp file missing: ' . $tmpFile);
|
||||
log_message('error', '[MyUpload] Temp file missing: ' . $tmpFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// ✅ 클라우드에 올라갈 "Key"를 직접 만든다 (로컬 경로 절대 넣지 말기)
|
||||
// 예시: upload/tmp/랜덤파일명 또는 upload/apt_file/{rcpt_no}/...
|
||||
// ✅ 클라우드에 올라갈 "Key"
|
||||
$objectKey = $filePath . $newName;
|
||||
|
||||
// 클라우드 업로드 (필수)
|
||||
$up = $this->upload_object_storage($objectKey, $tmpFile, 'file');
|
||||
|
||||
if ($up === false) {
|
||||
$this->set_error('upload_destination_cloud_error');
|
||||
$this->set_error('cloud_upload_failed');
|
||||
log_message('error', '[MyUpload] Cloud upload failed: ' . $objectKey);
|
||||
@unlink($tmpFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// (선택) tmp 파일 삭제
|
||||
// tmp 파일 삭제
|
||||
@unlink($tmpFile);
|
||||
|
||||
$this->s3_data = [
|
||||
'object_key' => $objectKey,
|
||||
'object_storage_url' => $up['object_storage_url'] ?? null,
|
||||
'origin_name' => $file->getClientName(),
|
||||
'file_name' => basename($objectKey), // xxxx.jpg
|
||||
'base_name' => pathinfo($objectKey, PATHINFO_FILENAME), // xxxx
|
||||
'ext' => pathinfo($objectKey, PATHINFO_EXTENSION), // jpg
|
||||
'file_name' => basename($objectKey),
|
||||
'base_name' => pathinfo($objectKey, PATHINFO_FILENAME),
|
||||
'ext' => pathinfo($objectKey, PATHINFO_EXTENSION),
|
||||
];
|
||||
|
||||
|
||||
log_message('debug', 's3_data=' . json_encode($this->s3_data ?? null, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
|
||||
log_message('info', '[MyUpload] Cloud upload success: ' . $objectKey);
|
||||
|
||||
return $this->s3_data;
|
||||
}
|
||||
@@ -386,6 +387,7 @@ class MyUpload
|
||||
'Key' => ltrim($object_storage_upload_path, '/'),
|
||||
'Body' => $blobData,
|
||||
'ACL' => 'public-read',
|
||||
'ContentType' => 'image/jpeg',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user