我怎么可以检查图像的尺寸,这样我可以proportionaly减少他们避免失真? [英] How can I check the dimensions of a image so that I can reduce them proportionaly to avoid distortion?

查看:218
本文介绍了我怎么可以检查图像的尺寸,这样我可以proportionaly减少他们避免失真?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当人写了一篇文章,他们提交的照片来说明该事件。但是,为了显示空间不宽。所以,我想,以减少他们的宽度和/或高度,同时保持其原有的比例。否则,图像被扭曲。

When people write an article, they submit a photo to illustrate the event. But, the space to display is not wide. So, I'd like to reduce they width and/or height while keeping their original proportion. Otherwise, the image gets distorted.

比方说,最大宽度300像素为。更宽点儿比会看到它的宽度减少到300像素。不过,我想的高度将减少到相同的比例。例如:600 * 800将成为300像素x 400像素。所以,我需要能够检查尺寸

Let's say the max width is 300px. Anyting wider than that would see its width reduced to 300px. However, I'd like the Height to be reduced to the same proportion. For instance: 600 x 800 will become 300px x 400px. So, I need to be able to check the dimensions

我如何检查这些方面?
我什么时候检查呢? (我)上传后,(ii)在从数据库retreiving?...

How do I check those dimensions? When do I check them? (i) after uploading, (ii) while retreiving from the database?...

感谢您的帮助。

推荐答案

我会建议你上传后检查图像并保存两个版本的数据库 - 原始和调整的版本。你应该服务于大小版本的文章。 。这样,你调整图像大小只有一次

I would suggest you check the image after upload and save two versions to the database - the original and the resized version. You should serve the resized versions with the article. That way you resize the image only once.

有关的代码示例到这里看看:

For code example take a look here:

C#:调整图像大小,同时保持宽高比和最大高度

这篇关于我怎么可以检查图像的尺寸,这样我可以proportionaly减少他们避免失真?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆