如何以压缩格式将图像存储在ASP.NET C#数据库中 [英] how to store images in database in asp.net C# with compress format

查看:75
本文介绍了如何以压缩格式将图像存储在ASP.NET C#数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的代码项目团队,

在我们公司的日常库中,图像是上传的,问题很多是封面图像.

而且我想成为数据映像,将问题降到最低.

因此,请提供如何使用C#在asp.net中以数据库格式压缩格式存储图像.

这是个大问题,请提供帮助.

热烈的感谢
罗希特·库玛·辛格(Rohit Kumar Singh)
9810353598

Dear Code Project Team,

In our company daily bases image are upload and problem a lot space are cover image .

And i want to be data image to minimum issue.

So,please provide how to store image in database form compress format in asp.net using C#.

It''s big issue please provide help.

warm thank''s
Rohit Kumar Singh
9810353598

推荐答案

ASP.NET无法在任何DB中存储任何内容,这是创建HTML的框架.但是,C#当然可以.问题是,有人在向您发送BMP吗?如果不是,如果它们是jpg,PNG或其他格式,则它们已经被压缩,因此,除非您希望将它们调整得小很多,否则根本不会减小文件的大小.如果它们是BMP,则将其转换为JPG,您会看到大小减小.
ASP.NET cannot store anything in any DB, it''s a frame work for creating HTML. But, C# can, of course. The thing is, are people sending you BMPs ? If they are not, if they are jpgs, or PNGs, or whatever, then they are already compressed, so unless you want to resize them to be a lot smaller, you are not going to get the file sizes down at all. If they are BMPs, convert to JPG and you''ll see the size drop.


您可以在此处进行以下操作.

1.如果图像大小不同,请对其进行标准化(您可以使用c#调整其大小)

2.转换为标准格式.例如jpg.那里有很多代码将向您展示如何执行此操作.

3.优化它.您可以通过代码再次进行此操作(只需将其谷歌搜索即可).

如果您将它们压缩,则问题在于您仍在存储昂贵的文件,并且还存在必须压缩以存储该文件然后在需要显示文件时将其解压缩的延迟-由于时间原因而导致的成本高昂.

最好的选择是标准化和优化图像.从经验来看,我们可以容纳约一百万张图像.图像具有各种形状和尺寸.但是,我们只需要存储该人的头部和肩膀快照即可.因此,我们拍摄图像,自动检测头部和肩膀,对其进行裁剪,然后将其作为字节数组存储在DB中.完成所有这些操作后,图像大小始终约为9k.

希望能帮助您指出正确的方向
A few things that you could do here.

1. If the images are different sizes, the standardize them (you can resize them using c#)

2. Convert to a standard format. e.g. jpg. There is plenty of code out there that will show you how to do this.

3. optimize it. You can do this again through code (just google it).

If you zip them, the issue is that you are still storing a file which is costly and also having a delay of having to zip it to store it and then unzip it when you need to show it --costly due to time.

The best bet is to standardize and optimize the image. Speaking from experience, we house about 1 million images. The images come in all shapes and sizes; however, we only need the head and shoulders shot of the person to be stored. Thus, we take the image, auto detect the head and shoulders, crop it and then store it in the DB as a byte array. After all of this, the image size is about 9k consistantly.

Hope that helps point you in the right direction


这篇关于如何以压缩格式将图像存储在ASP.NET C#数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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