Reducing size of image returned by view We are storing a list of images in a table in an image column. These are stored as their raw image size so they can be viewed in their details at full resolution.

The problem I have is I want to show them in a listing in our application and I just want to show them as thumbnails. When I retrieve them via a view our entityFramework code bombs with out of memory errors trying to resolve all the images into fields in the code.

I'm wanting to know whether I can resize the image column at the database view level before it hits the application. i.e. In our view have a function that takes the full size image and resizes it to 80x80 and returns it. e.g.

Select fxShringImage(EntityImage) From EntityImage


Any ideas? Is this possible?
First and foremost do not use the IMAGE data type, is an old deprecated type:


  text , text, and image data types will be removed in a future version
  of Microsoft SQL Server. Avoid using these data types in new
  development work, and plan to modify applications that currently use
  them. Use nvarchar(max), varchar(max), and varbinary(max) instead.


You need to store multiple images, one for each resolution desired (full/preview/thumb). In general these resized images must be generated during the upload of the image. Strictly speaking it is possible to generate the preview/thumb on-demand on first display, or even on each access (ie. not saved), but this is seldom the right choice. In general a file is uploaded once and viewed multiple times, so it makes more sense to pay the penalty of generating the thumbnail at upload (write) time. And users are perceive the site/application as 'slow' if the image is generated on-demand on first access. See Asynchronous Execution for how to run jobs like uploaded image re-size in an reliable asynchronous manner.

As for loading fat content into entity lists in the client (irrelevant whether is images, documents or whatever other BLOB), just don't do it. You will kill your server, your network, your appserver, your client app, everything. Load narrow lists with only the fields needed for display. Lazy load on-demand expensive content. This is CS101 and applies to every technology.

PS. I won't even go into the topic of whether is better to store images on disk or in db. I assume you already did due diligence for that.