如何使用宽高比调整图像大小并以预定义的大小显示? [英] how to resize images with aspect ration and display in a pre defined size?

查看:84
本文介绍了如何使用宽高比调整图像大小并以预定义的大小显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的网站上有一些特定尺寸的图像显示区域。如果我使用图像宽高比来重新调整图像大小,然后根据显示区域大小在网站上显示,那么它会调整宽高比,但是固定在网站上显示的大小会丢失。



例如,如果想要显示徽标图像,其原始尺寸的宽度和高度为250 x 100但是当我按照宽高比调整尺寸并在网站上显示为方形时然后它在所需的高度和宽度上失去并以较小的高度显示它并且在宽度上延伸,这看起来像丢失的像素图像。请注意,纵横比主要是维持,但是当我上传矩形徽标图像时,正方形的背景不会被完全占用。



我只是想显示全部具有预定义尺寸的正方形形状的徽标图像均匀地适合所有图像并占据整个正方形区域,并且不管图像的大小如何都不留下正方形区域或背景的空白空间。



提前致谢。

解决方案

image_handler 您查询的最佳解决方案



替代代码

Resize-and-Compress-Image-in-Csharp 看到这个也

hi,

I have a few certain sizes of image displaying areas on my website. If I use image aspect ratio to re size the image and then display on the website according to the display area size then it does resizing in the aspect ratio but the size which is fixed for displaying on the website is lost.

For instance, if the want to display a logo image whose original size in width and height is 250 x 100 but when I re size with aspect ration and display on the website in a square shape then it loses on desired height and width and displays it in smaller in height and stretches in width which apparently looks like lost pixels image. Please note that aspect ratio is maintained principally but the background of the square does not get occupied fully when I upload a rectangle logo image.

I just simply want to display all the logo images in the square shape with the predefined size to fit all the images equally & occupy the full square area and not leave blank space of the square area or the background whatever the size of the image may be.

Thanks in advance.

解决方案

image_handler best solution for your query

alternative code
Resize-and-Compress-Image-in-Csharp see this also


这篇关于如何使用宽高比调整图像大小并以预定义的大小显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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