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
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
Basicly to enable CLR on the SQL Server:
sp_configure 'clr enabled', 1
GO
RECONFIGURE
GO
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
}
}
Compile the assembly
csc /target:library ResizeImageProc.cs
Load the assembly in the SQL Server:
CREATE ASSEMBLY ResizeImageAssembly from 'c:\ResizeImageProc.dll' WITH PERMISSION_SET = SAFE
Create the proc
CREATE PROCEDURE ResizeImage AS EXTERNAL NAME ResizeImageAssembly.ResizeImageProc.ResizeImage
After that you can call it like a normal proc. For example:
EXEC ResizeImage(1,800,600)