如何调整存储在sqlserver中的图像? [英] How to resize images stored in sqlserver?

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

问题描述

我有一些图像存储在sql server数据库中,我现在正以原始大小显示图像。但我想调整图像大小,以便它们在互联网上加载速度更快。想知道我该怎么做?

我遇到了这个点击这里 [ ^ ]但我不确定这是否适用于在sql server数据库中以varbinary格式存储的图像。

I have some images stored in the sql server database and i am displaying the images in their original size at the moment. But i want to resize the images so that they load faster over internet. Want to know how can i do this?
I came across this CLICK HERE[^] But i am not sure if this will work in case of images stored in varbinary format in sql server database.

推荐答案

问题可分为两部分:1)如何在数据库中存储/检索图像? 2)如何调整图像大小(这称为重采样)?基本答案是:你应该分别拿两个。检索图像,重新取样(你可以动态地进行,不用将图像存储在临时文件中),再次存储。



至于第一部分,老实说,回答一个被问过并经过多次回答的问题并不好: http://www.codeproject.com/search.aspx?q=database+%28image+OR+images+OR+bitmap+OR+bitmaps%29+ C%23& doctypeid = 5 [ ^ ]。



至于重新取样:你可以使用 System.Drawing 。请参阅我过去的答案以获取更多详细信息:

调整大小vb.net中的图片 [ ^ ],

阅读大Tiff和JPEG文件(> ;(23000 x 23000)pix)在一个流。并实时显示部分内容。 [ ^ ]。







我不想这么说将重采样图像存储回数据库是必须的。您可以存储更小尺寸的图像的其他版本,或者您无法更改数据库,只能在每次请求时动态重新采样图像,只有当您需要显示它们时。



-SA
The question can be split in two parts: 1) how to store/retrieve images to/from database? 2) how to resize images (this is called resampling)? The basic answer is: you should take the two separately. Retrieve an image, resample it (you can do it on the fly, without storing images in temporary files), store it again.

As to the first part, honestly, it's not good to answer a question which has been asked and answered so many times: http://www.codeproject.com/search.aspx?q=database+%28image+OR+images+OR+bitmap+OR+bitmaps%29+C%23&doctypeid=5[^].

As to resampling: you can use System.Drawing. Please see my past answers for further detail:
resize image in vb.net[^],
Read Big Tiff and JPEG files (>(23000 x 23000) pix) in a stream. And display part of it to the screen in realtime.[^].



I did not want to say that storing resample images back in the database is a must. You can store additional versions of images, of smaller sizes, or you can not change the database at all but resample images on the fly on each request, only when you need to display them.

—SA


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

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