Imaging in .NET

Published 27 July 04 02:49 AM

I was playing around with an ASP project and used the ASPImage from serverobjects.com to do some stuff in ASP to resize and change DPI, etc.

But I wanted to do this in ASP.NET so that I could mass change the image sizes and create thumbnails (sort of).  So I did a google search of [image resize .net] and I got some interesting links and some were good and others were not.  I found this link on the second page to resize images and I tweaked it to make them the size I wanted to and to keep proportions correct.  I was surprised how easy it was to get it to generate thumbnails for me. 

I then went after changing the DPI of the image to 72.  By default, I found that the Framework uses 96 dpi for it’s images and that if I used the System.Drawing.Image.SetResolution(int, int) that I could change it from 96 to 72.  One thing I found that I could not change the original graphics DPI, I had to copy that image into the new graphic at that dpi.  It worked and I was very happy to learn this.  Not earth shattering, but a new one for me.

Happy Imaging…

Filed under: ,

Comments

# AdrianJMartin said on July 27, 2004 2:27 AM:
The System.Drawing.Imaging seem to be a good starting point. But it lacks support for many features. Like format conversion, OK you can convert formats but you can't access all the options of each file format.

For instance reading/writing IPCT from a JPEG, GIF transparency etc.

Was the library started and the the guys dragged of to Longhorn?

# Scott McCulloch said on July 27, 2004 3:06 AM:
There are a lot of imaging samples in the ASP.NET Developers Cookbook, http://www.samspublishing.com/title/0672325241

You can download the code online.
# Jeff Parker said on July 27, 2004 6:13 AM:
http://www.asp101.com/forum/display_message.asp?mid=198767

Is some code I posted out on ASP101 a long time ago. This takes an image of anytype resizes it via the loweest parameter on height and width, and then saves it out as a JPG. It could also easily be modified to accept an arguement on the quality, however for my needs it is just doing 100%.

I do agree that GIF support could be a lot better especially now that the patent on GIFs has expired.
Anonymous comments are disabled

This Blog

Syndication

Page view tracker