使用sql查询将图像大小从150 * 150更改为70 * 70? [英] Change Image size from 150*150 to 70*70 in using sql query?

查看:101
本文介绍了使用sql查询将图像大小从150 * 150更改为70 * 70?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将图像存储在SQL Server 2008 R2数据库的varBinary(max)列中,名为:image1,大小为150 * 150。我添加了另一个名为image2 varBinary(max)的列,我需要使用image1中相同的图像更新此列,但大小为70 * 70。是否可以使用sql查询执行此操作。

I am storing image in SQL server 2008 R2 database in varBinary(max) column named: image1 which is of size 150*150. I have added another column named image2 varBinary(max) and i need to update this column with the same image in image1 but with 70*70 size. Is it possible to do this using sql query.

我试图找到查询但没有得到任何线索如何执行此操作。如果有人以前做过这个以及怎么做,请告诉我?

I have tried to find the query but not getting any clue how to do this. Please let me know if anyone has done this before and how?

推荐答案

我同意每个人的观点,但如果你真的想要或者必须,您可以在SQL Server上启用CLR集成,创建可以调整图像大小的程序集,然后从触发器或proc调用它。它不是很难。这是一个描述该过程的页面: http:// msdn。 microsoft.com/en-us/library/ms254498(VS.80).aspx

I agree with everyone's points here, but if you really wanted to or had to, you could enable CLR integration on the SQL Server, create an assembly that could resize your image, and then call it from a trigger or proc. Its not very hard. Here a page that describes the process: http://msdn.microsoft.com/en-us/library/ms254498(VS.80).aspx

基本上在SQL Server上启用CLR:

Basicly to enable CLR on the SQL Server:

sp_configure 'clr enabled', 1
GO
RECONFIGURE
GO

创建ac#assembly以调整图像大小:

Create a c# assembly to resize your image:

using System;
using System.Data;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;

public class ResizeImageProc
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void ResizeImage(int ImageID, int width, int height)
    {
       //TODO: ResizeImage Code
    }
}

编译程序集

csc /target:library ResizeImageProc.cs 

在SQL Server中加载程序集:

Load the assembly in the SQL Server:

CREATE ASSEMBLY ResizeImageAssembly from 'c:\ResizeImageProc.dll' WITH PERMISSION_SET = SAFE

创建过程

CREATE PROCEDURE ResizeImage AS EXTERNAL NAME ResizeImageAssembly.ResizeImageProc.ResizeImage

之后你可以像普通的proc一样调用它。例如:

After that you can call it like a normal proc. For example:

EXEC ResizeImage(1,800,600)

这篇关于使用sql查询将图像大小从150 * 150更改为70 * 70?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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