ShopPlatform.Web 1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
로딩중...
검색중...
일치하는것 없음
ShopPlatform.Services.OgImageGenerator 클래스 참조

더 자세히 ...

정적 Public 멤버 함수

static void EnsureDefault (string wwwrootPath)
static string EnsureShopOg (string wwwrootPath, string slug, string shopName, string description, string baseUrl)

정적 Private 멤버 함수

static void DrawRoundRect (Graphics g, Brush brush, Rectangle rect, int radius)

정적 Private 속성

const int W = 1200
const int H = 630

상세한 설명

샵별 OG 미리보기 이미지(1200×630 PNG)를 동적으로 생성합니다. 이미 파일이 있으면 건너뜁니다.

OgImageGenerator.cs 파일의 17 번째 라인에서 정의되었습니다.

멤버 함수 문서화

◆ DrawRoundRect()

void ShopPlatform.Services.OgImageGenerator.DrawRoundRect ( Graphics g,
Brush brush,
Rectangle rect,
int radius )
inlinestaticprivate

Draw Round Rect 작업을 수행합니다.

매개변수
gg에 사용할 Graphics 값입니다.
brushbrush에 사용할 Brush 값입니다.
rectrect에 사용할 Rectangle 값입니다.
radiusradius에 사용할 int 값입니다.

OgImageGenerator.cs 파일의 267 번째 라인에서 정의되었습니다.

268 {
269 using var path = new GraphicsPath();
270 path.AddArc(rect.X, rect.Y, radius * 2, radius * 2, 180, 90);
271 path.AddArc(rect.Right - radius * 2, rect.Y, radius * 2, radius * 2, 270, 90);
272 path.AddArc(rect.Right - radius * 2, rect.Bottom - radius * 2, radius * 2, radius * 2, 0, 90);
273 path.AddArc(rect.X, rect.Bottom - radius * 2, radius * 2, radius * 2, 90, 90);
274 path.CloseFigure();
275 g.FillPath(brush, path);
276 }

다음에 의해서 참조됨 : EnsureDefault().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ EnsureDefault()

void ShopPlatform.Services.OgImageGenerator.EnsureDefault ( string wwwrootPath)
inlinestatic

기본 플랫폼 OG 이미지 생성 (shop-og-default.png).

매개변수
wwwrootPathwwwroot Path에 사용할 string 값입니다.

OgImageGenerator.cs 파일의 54 번째 라인에서 정의되었습니다.

55 {
56 if (!OperatingSystem.IsWindowsVersionAtLeast(6, 1)) return; // Linux는 건너뜀
57 var dir = Path.Combine(wwwrootPath, "img");
58 var path = Path.Combine(dir, "shop-og-default.png");
59 Directory.CreateDirectory(dir);
60 if (File.Exists(path)) return;
61
62 using var bmp = new Bitmap(W, H, PixelFormat.Format32bppArgb);
63 using var g = Graphics.FromImage(bmp);
64 g.SmoothingMode = SmoothingMode.AntiAlias;
65 g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
66
67 // 그라데이션 배경 (진한 남색 → 보라)
68 using var bg = new LinearGradientBrush(
69 new Rectangle(0, 0, W, H),
70 Color.FromArgb(0x1e, 0x1b, 0x4b), // indigo-950
71 Color.FromArgb(0x4c, 0x1d, 0x95), // violet-900
72 LinearGradientMode.ForwardDiagonal);
73 g.FillRectangle(bg, 0, 0, W, H);
74
75 // 장식 원 (반투명)
76 using var circleBrush = new SolidBrush(Color.FromArgb(30, 255, 255, 255));
77 g.FillEllipse(circleBrush, -120, -120, 480, 480);
78 g.FillEllipse(circleBrush, W - 300, H - 300, 500, 500);
79
80 // 쇼핑백 아이콘 영역 (흰 둥근 사각형)
81 var iconRect = new Rectangle(W / 2 - 60, 140, 120, 120);
82 using var iconBg = new SolidBrush(Color.FromArgb(40, 255, 255, 255));
83 DrawRoundRect(g, iconBg, iconRect, 24);
84 using var iconFont = new Font("Segoe UI Emoji", 52, FontStyle.Regular, GraphicsUnit.Pixel);
85 using var iconBrush = new SolidBrush(Color.White);
86 var iconSf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
87 g.DrawString("🛒", iconFont, iconBrush, new RectangleF(iconRect.X, iconRect.Y, iconRect.Width, iconRect.Height), iconSf);
88
89 // 메인 타이틀
90 using var titleFont = new Font("Malgun Gothic", 62, FontStyle.Bold, GraphicsUnit.Pixel);
91 using var titleBrush = new SolidBrush(Color.White);
92 var titleSf = new StringFormat { Alignment = StringAlignment.Center };
93 g.DrawString("ShopPlatform", titleFont, titleBrush, new RectangleF(0, 295, W, 80), titleSf);
94
95 // 부제목
96 using var subFont = new Font("Malgun Gothic", 30, FontStyle.Regular, GraphicsUnit.Pixel);
97 using var subBrush = new SolidBrush(Color.FromArgb(200, 255, 255, 255));
98 var subSf = new StringFormat { Alignment = StringAlignment.Center };
99 g.DrawString("나만의 온라인 쇼핑몰을 시작하세요", subFont, subBrush, new RectangleF(0, 378, W, 50), subSf);
100
101 // 하단 URL 배지
102 using var badgeBrush = new SolidBrush(Color.FromArgb(50, 255, 255, 255));
103 DrawRoundRect(g, badgeBrush, new Rectangle(W / 2 - 200, 470, 400, 46), 23);
104 using var urlFont = new Font("Malgun Gothic", 22, FontStyle.Regular, GraphicsUnit.Pixel);
105 using var urlBrush = new SolidBrush(Color.FromArgb(220, 255, 255, 255));
106 var urlSf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
107 g.DrawString("shop.codemaru.co.kr", urlFont, urlBrush, new RectangleF(W / 2 - 200, 470, 400, 46), urlSf);
108
109 bmp.Save(path, ImageFormat.Png);
110 }

다음을 참조함 : DrawRoundRect(), H, W.

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ EnsureShopOg()

string ShopPlatform.Services.OgImageGenerator.EnsureShopOg ( string wwwrootPath,
string slug,
string shopName,
string description,
string baseUrl )
inlinestatic

샵별 OG 이미지 생성 (og-{slug}.png) — 샵 이름/설명 포함.

매개변수
wwwrootPathwwwroot Path에 사용할 string 값입니다.
slugslug에 사용할 string 값입니다.
shopNameshop Name에 사용할 string 값입니다.
descriptiondescription에 사용할 string 값입니다.
baseUrlbase Url에 사용할 string 값입니다.
반환값
Ensure Shop Og 작업에서 생성한 string 결과입니다.

OgImageGenerator.cs 파일의 168 번째 라인에서 정의되었습니다.

169 {
170 if (!OperatingSystem.IsWindowsVersionAtLeast(6, 1))
171 return "/img/shop-og-default.png"; // Linux fallback
172 var dir = Path.Combine(wwwrootPath, "img", "og");
173 var fileName = $"og-{slug}.png";
174 var path = Path.Combine(dir, fileName);
175 Directory.CreateDirectory(dir);
176
177 // 항상 재생성 (설정 변경 반영)
178 using var bmp = new Bitmap(W, H, PixelFormat.Format32bppArgb);
179 using var g = Graphics.FromImage(bmp);
180 g.SmoothingMode = SmoothingMode.AntiAlias;
181 g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
182
183 // 배경
184 using var bg = new LinearGradientBrush(
185 new Rectangle(0, 0, W, H),
186 Color.FromArgb(0x1e, 0x1b, 0x4b),
187 Color.FromArgb(0x4c, 0x1d, 0x95),
188 LinearGradientMode.ForwardDiagonal);
189 g.FillRectangle(bg, 0, 0, W, H);
190
191 // 장식
192 using var circleBrush = new SolidBrush(Color.FromArgb(25, 255, 255, 255));
193 g.FillEllipse(circleBrush, -100, -100, 400, 400);
194 g.FillEllipse(circleBrush, W - 250, H - 250, 450, 450);
195
196 // 샵 이름
197 var nameText = shopName.Length > 18 ? shopName[..18] + "…" : shopName;
198 using var nameFont = new Font("Malgun Gothic", 72, FontStyle.Bold, GraphicsUnit.Pixel);
199 using var nameBrush = new SolidBrush(Color.White);
200 var centerSf = new StringFormat { Alignment = StringAlignment.Center };
201 g.DrawString(nameText, nameFont, nameBrush, new RectangleF(60, 200, W - 120, 90), centerSf);
202
203 // 설명
204 if (!string.IsNullOrEmpty(description))
205 {
206 var descText = description.Length > 40 ? description[..40] + "…" : description;
207 using var descFont = new Font("Malgun Gothic", 32, FontStyle.Regular, GraphicsUnit.Pixel);
208 using var descBrush = new SolidBrush(Color.FromArgb(210, 255, 255, 255));
209 g.DrawString(descText, descFont, descBrush, new RectangleF(60, 305, W - 120, 55), centerSf);
210 }
211
212 // 구분선
213 using var linePen = new Pen(Color.FromArgb(60, 255, 255, 255), 1);
214 g.DrawLine(linePen, 100, 390, W - 100, 390);
215
216 // 하단 플랫폼 표시
217 using var platformFont = new Font("Malgun Gothic", 24, FontStyle.Regular, GraphicsUnit.Pixel);
218 using var platformBrush = new SolidBrush(Color.FromArgb(160, 255, 255, 255));
219 g.DrawString($"🛒 {baseUrl.Replace("https://", "").Replace("http://", "")}/{slug}",
220 platformFont, platformBrush, new RectangleF(60, 415, W - 120, 40), centerSf);
221
222 bmp.Save(path, ImageFormat.Png);
223 return $"/img/og/{fileName}";
224 }

다음을 참조함 : H, W.

멤버 데이터 문서화

◆ H

const int ShopPlatform.Services.OgImageGenerator.H = 630
staticprivate

H 값을 보관합니다.

OgImageGenerator.cs 파일의 36 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : EnsureDefault(), EnsureShopOg().

◆ W

const int ShopPlatform.Services.OgImageGenerator.W = 1200
staticprivate

W 값을 보관합니다.

OgImageGenerator.cs 파일의 27 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : EnsureDefault(), EnsureShopOg().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: