将 JPEG 图像大小调整为固定宽度,同时保持纵横比不变
如何将 JPEG 图像的大小调整为固定宽度,同时保持纵横比?以简单的方式,同时保持质量。
How would you resize a JPEG image, to a fixed width whilst keeping aspect ratio? In a simple way, whilst preserving quality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这只会在垂直轴上缩放:
This will scale in the vertical axis only:
如果要将宽度减少 25% 至固定值,则必须将高度减少 25%。
如果要将宽度增加 25% 达到固定值,则必须将高度增加 25%。
这真的很简单。
If you are reducing the width by 25 percent to a fixed value, you must reduce the height by 25 percent.
If you are increasing the width by 25 percent to a fixed value, you must increasing the height by 25 percent.
It's really straight forward.
假设有一个(
双宽度
)变量:最后您将得到一个宽度x高度的新图像,然后,您需要刷新图形并保存新的图像。
Assuming there is a (
double width
) variable:In the end you´ll have a new image with widthxheight, then, you´ll need to flush the graphics e save the imgnew.
我想如果你搜索一下的话,会有很多这样的例子。这是我常用的...
调用代码示例...
I think there are plenty of samples of this if you search for them. Here's the one I commonly use...
Example of the calling code...
快速搜索代码项目发现了以下文章。它允许调整图像大小,该图像接受布尔值来限制新图像以保持原始宽高比。我不确定质量如何,因为没有提供屏幕截图。请参阅文章此处< /a>
A quick search on code project has found the following article. It allows for resizing of images which accepts a boolean to restrain the new image to keep the originals aspect ratio. I'm unsure of what the quality is like as no screenshots were provided. See the article here