56 if (!OperatingSystem.IsWindowsVersionAtLeast(6, 1))
return;
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;
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;
68 using var bg =
new LinearGradientBrush(
69 new Rectangle(0, 0,
W,
H),
70 Color.FromArgb(0x1e, 0x1b, 0x4b),
71 Color.FromArgb(0x4c, 0x1d, 0x95),
72 LinearGradientMode.ForwardDiagonal);
73 g.FillRectangle(bg, 0, 0,
W,
H);
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);
81 var iconRect =
new Rectangle(
W / 2 - 60, 140, 120, 120);
82 using var iconBg =
new SolidBrush(Color.FromArgb(40, 255, 255, 255));
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);
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);
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);
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);
109 bmp.Save(path, ImageFormat.Png);
168 public static string EnsureShopOg(
string wwwrootPath,
string slug,
string shopName,
string description,
string baseUrl)
170 if (!OperatingSystem.IsWindowsVersionAtLeast(6, 1))
171 return "/img/shop-og-default.png";
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);
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;
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);
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);
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);
204 if (!
string.IsNullOrEmpty(description))
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);
213 using var linePen =
new Pen(Color.FromArgb(60, 255, 255, 255), 1);
214 g.DrawLine(linePen, 100, 390,
W - 100, 390);
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:
220 platformFont, platformBrush,
new RectangleF(60, 415,
W - 120, 40), centerSf);
222 bmp.Save(path, ImageFormat.Png);
223 return $
"/img/og/{fileName}";
267 private static void DrawRoundRect(Graphics g, Brush brush, Rectangle rect,
int radius)
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);
275 g.FillPath(brush, path);