如何在C#中更改图片文件的尺寸?

发布于 2024-09-07 00:43:18 字数 152 浏览 0 评论 0原文

我正在开发一个 MVC Web 应用程序。我上传一张图像以将其用作系统徽标。现在,如果我选择图像并上传它,则可以轻松替换它,直到图像文件尺寸不大。对于大尺寸的文件,我需要将其尺寸减小到较小的尺寸,以使其看起来像系统徽标。我的徽标的首选尺寸是 100x75。如何减小文件大小? 谢谢, 卡皮尔

I am working a mvc web app. I upload a image to use it as system logo. Now if I select image and upload it, it can be replaced easily until image file is not of large dimesion. For file with large dimension i need to reduce its size to some smaller size to make it look like a system logo. Preferable size for my logo is 100x75. How can I reduce the file dimesion?
THanks,
kapil

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卸妝后依然美 2024-09-14 00:43:19

试试这个。
我在msdn中找到了它,并且有效。

Bitmap map = new Bitmap(Image.FromFile("F:\\1.jpg"), new Size(20, 20));
map.Save("F:\\5.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

try this.
I found it in the msdn, and it works.

Bitmap map = new Bitmap(Image.FromFile("F:\\1.jpg"), new Size(20, 20));
map.Save("F:\\5.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
小兔几 2024-09-14 00:43:19

您可以使用 System.Drawing< 中的类/code>命名空间。

有关详细信息,请参阅本教程

You can use the classes that are in the System.Drawing namespace.

See this tutorial for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文