如何在具有控制图像大小的SQL数据库中存储图像? [英] How can store Image in SQL Database with control Image Size?

查看:88
本文介绍了如何在具有控制图像大小的SQL数据库中存储图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在具有控制图像大小的SQL数据库中存储图像?
我想以固定大小(300KB)将图像存储在数据库表中.现在如何将映像大小从2500KB减少到300KB?

How can store Image in SQL Database with control Image Size?
I want to store image in database table within a fixed size (300KB). Now how can i reduce a Image size from 2500KB to 300KB?

推荐答案

您可以使用Image/CLOB数据类型存储映像文件.但是,图像在表中存储为字节而不是图像,因此您无法提供大小.如果对图像字段使用字节"数据类型,则可以设置大小.您需要先将图像转换为它们对应的字节,然后才能保存到数据库中.同样,当您从数据库中选择图像时,必须转换为正确的图像格式,然后才能在任何控件中显示图像.
You can use Image/CLOB datatypes to store your image files. However images are stored as bytes rather than image in the tables and you cannot provide size. If you are using "Byte" datatype for image field then you can set the size. You need to convert image to their corresponding bytes before you can save into the database. similarly when you select from the database, you have to convert in to the correct image format before you can display image in any controls.


请参阅此

http://www.aspdotnet-suresh.com/2011/01/how-to-insert-images-into-database-and.html [
Refer to this

http://www.aspdotnet-suresh.com/2011/01/how-to-insert-images-into-database-and.html[^]


嘿,您可以将图像存储在varbinary列中在数据库中,然后从那里直接拉出图像.只需设置图像的值,然后再将其转换为字节数组,然后将其插入即可.然后,只需将值读回即可.如果您需要代码示例,我们将很乐意提供.
Hey you can store you image in a varbinary column in the db and pull the image directly out from there. Just set the values of the image before converting it to a byte array and then insert it. Then simply read the values back out. If you need a code sample I will gladly provide it.


这篇关于如何在具有控制图像大小的SQL数据库中存储图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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