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)
As has been said in a few of the comments, SQL is a data storage system and is unable to edit your images.
I suggest that you perform a one-time update on the table using your preferred language (c# etc) fetching each image and resizing it before updating it back into the table.
Then from that point on ensure that any images inserted into the table are resized before they are inserted.