简体   繁体   English

在C#中使用缩放和裁剪来调整图像大小

[英]Resize image with scale and crop in C#

When I upload an image, it is quite big some times, I have to create its thumbnail in a specific way. 上传图像时,有时它会很大,因此必须以特定方式创建其缩略图。

What I want is if I declare the size of 96x69 for the thumbnail, those uploaded images which are scalable to this resolution should be scaled, and those uploaded images which are quite different in wxh , example 1000x1000 , they should be cropped to maximum better scalability. 我想要的是,如果我声明缩略图的大小为96x69 ,则应缩放可缩放到此分辨率的那些已上传图像,并且那些在wxh中完全不同的上传图像(例如1000x1000 )应裁剪为最大的更好可缩放性。 Is there any fast library or built in code as I have tried to do in my own way but it is not that perfect? 是否有快速的库或内置的代码,以我自己的方式尝试完成,但不是那么完美?

在此处输入图片说明

I strongly recommend ImageResizer which can be found freely on the Nuget . 我强烈建议您在Nuget上免费找到ImageResizer Basically, resizing images is a sophisticated procedure that may be included variety techniques such as cropping, scaling, resizing, moving, trimming, etc. that implementing each of these methods is not an easy job. 基本上,调整图像大小是一个复杂的过程,可能包含多种技术,例如裁切,缩放,调整大小,移动,修剪等,实现这些方法中的每一个都不容易。 Hence, it's better to use image-resizer. 因此,最好使用图像缩放器。

you can use jquery for solving this problem. 您可以使用jquery解决此问题。 If its feasible in your project to do it client side. 如果在您的项目中可行,请在客户端进行。 Check these link here.. http://www.jqueryrain.com/demo/jquery-crop-image-plugin/ and https://code.google.com/p/resize-crop/ this one is best and easiest i guess. 这里检查这些链接.. http://www.jqueryrain.com/demo/jquery-crop-image-plugin/https://code.google.com/p/resize-crop/这一个是最好的和最简单的我猜测。

If you want to do it server side for some reason, then have a look on solution mentioned in this question. 如果出于某种原因要在服务器端执行此操作,请查看此问题中提到的解决方案。 Which free image resizing library can I use for resizing and probably serving images? 我可以使用哪个免费的图像大小调整库来调整大小并提供图像?

Hope this will solve your problem. 希望这能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM