在MVC C#中制作图像缩略图 [英] Make image thumbnail in MVC C#

查看:71
本文介绍了在MVC C#中制作图像缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将用户上传的大图像缩略图缩小,点击此图片,显示用户在mvc c#上传的实际较大的图像实际尺寸。 />
有人可以帮助我吗?



我尝试过:



如何将用户上传的大图像缩略图缩小,点击此图像,显示用户在mvc c#上传的实际更大的图像实际尺寸。

有人可以帮我吗?

解决方案

上传完成后你应该保存已调整大小的图像和原始图像。



假设您将上传的图像保存在 Images / UserImages 中,然后您可以在图像/缩略图中保存上传图像的已调整大小的版本。您可以将图像大小调整为您想要的任何大小;代码项目中有很多文章。



之后你可以写html为



< pre lang =HTML> < a href =' / Images / UserImages / MyImage。 jpg>
< img src ='
/ Images / Thumbnail / MyImage.jpg / >
< / a >



因此,点击缩略图会将您重定向到您可以从中获取原始尺寸图像的图像路径。


how to make thumbnail of large image to small which is uploaded by user and by clicking on this image it shows the actual larger real size of image which is uploaded by user in mvc c# .
could anyone help me?

What I have tried:

how to make thumbnail of large image to small which is uploaded by user and by clicking on this image it shows the actual larger real size of image which is uploaded by user in mvc c# .
could anyone help me?

解决方案

You should saved resized image along with original image after upload complete.

Say you would save uploaded image in Images/UserImages then you can save uploaded image's resized version in Images/Thumbnails. You can resize image to whatever size you want; there are number of articles in codeproject for that.

After that you can write html as

<a href='/Images/UserImages/MyImage.jpg">
 <img src='/Images/Thumbnail/MyImage.jpg" />
</a>


So clicking on thumbnail will redirect you to image path from where you can get original size image.


这篇关于在MVC C#中制作图像缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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