智能调整图像预览大小?

时间:2022-10-31 10:20:32

im using a image preview that allows me to add css styles to the previews that pops up.

即时通讯使用图像预览,允许我将css样式添加到弹出的预览中。

now, some images are larger than the screen so you will just see a portion of them, while other images are very small so you don't have to resize them.

现在,有些图像比屏幕大,所以你只能看到它们的一部分,而其他图像非常小,所以你不必调整它们的大小。

is there a way to only resize the larger images and not touching the smaller ones, eg. only resize images with width or height larger than 400 px?

有没有办法只调整较大的图像,而不是触及较小的图像,例如。仅调整宽度或高度大于400像素的图像?

any other approaches to make the larger ones fit into the screen without affecting the smaller ones would be appreciated cause if i just use width=400px and height=400px all images will be at that size and the proportion will be wrong. and for smaller images you will se very large pixels.

如果我只使用width = 400px和height = 400px,那么任何其他方法可以使较大的那些适合屏幕而不影响较小的那些因为所有图像都将处于该大小并且比例将是错误的。对于较小的图像,您将获得非常大的像素。

thanks in advance

提前致谢

1 个解决方案

#1


2  

Seam carving javascript implementation is what I call smart resizing of images :)

Seam雕刻javascript实现是我所谓的智能调整大小的图像:)

Anyway, in Javascript, you can implement your logic depending on the width and height properties of the Image object.

无论如何,在Javascript中,您可以根据Image对象的width和height属性实现逻辑。

Also have a look at this page, the author uses jQuery to resize images larger than specified dimensions.

另外看一下这个页面,作者使用jQuery来调整大于指定尺寸的图像。

#1


2  

Seam carving javascript implementation is what I call smart resizing of images :)

Seam雕刻javascript实现是我所谓的智能调整大小的图像:)

Anyway, in Javascript, you can implement your logic depending on the width and height properties of the Image object.

无论如何,在Javascript中,您可以根据Image对象的width和height属性实现逻辑。

Also have a look at this page, the author uses jQuery to resize images larger than specified dimensions.

另外看一下这个页面,作者使用jQuery来调整大于指定尺寸的图像。