Share via


Image Generation is released to CodePlex

I'm really happy to announce that earlier this week we released a new feature called Image Generation to the ASP.NET CodePlex site. You can get a link directly to the page supporting this feature by clicking on: https://www.codeplex.com/aspnet/Wiki/View.aspx?title=WebForms&referringTitle=Home.

 

There was a feature that was in Beta 1 for Visual Studio 2005 (Whitbey) called DynamicImage that provided a control for generating images and an image service for serving them. This feature was sadly cut because some of the other parts of the framework it depended on were cut.

 

Image Generation is basically work to bring this type of feature back into the framework. Here are some of the highlights of what this new feature does:

 

New GeneratedImage ASP.NET control. This control is a derivative of asp:Image control that supports being hooked up to an Image Handler and passing parameters to it. If you put this control on a page and go into design mode it will have chrome attached to it that when clicked will automatically generate an ImageHandler and wire the control to the URL of the ImageHandler. Parameters such as the primary id and timestamp can be databound to the control and will automatically be passed to the handler.

 

ImageHandler which is an implementation of IHttpHandler that provides support for many image based things:

  • Transforms (resizing, watermarks, user defined transforms)
  • Client-side caching
  • Server side caching
  • Access to parameters passed from the GeneratedImage control
  • Provide simple mechanics for returning images

 

If you click to the site there are three samples of how to use GeneratedImage:

  • Simple Generated Image - this shows how you would create a simple bitmap and return it
  • Databased Images - shows how you would use this feature to display images that are stored in a database
  • Custom Image Transforms - shows how to write a custom image transform that adds a ASP.NET logo to an image

We are considering adding this feature in the next version of .NET and would love feedback. Please download and try and it out and let us know what you think!

Comments

  • Anonymous
    August 21, 2008
    PingBack from http://hubsfunnywallpaper.cn/?p=1778

  • Anonymous
    August 21, 2008
    I've done my share of GDI+ generation... I think I'd like to do less of it rather than more ;) We have run into a lot of issues with performance, accessibility, and integration with 3rd party vendors. http://tinyurl.com/6ym4ab

  • Anonymous
    August 21, 2008
    Yes, add it please, no need to consider! One detail I have run into implementing this kind of thing (which I hope you guys will look into): most people do not specify the actual encoding for the image. I don't mean the reponse type, but the actual way GDI will create the image. I ended up generating PNG's (seems to be the default) without realising it and specifying jpeg as the content type for the response. All browsers displayed the image fine, which is great, but it hides the fact that my implementation was wrong. Just something to remember. Ideally, when transforming or working with existing images, this handler should take care to use the correct encoding (same as the original) so as not to turn a jpeg into a png. Thanks!

  • Anonymous
    August 21, 2008
    The comment has been removed

  • Anonymous
    August 22, 2008
    Great tool. Include it in the next release. Writing your own GDI generation is very time consuming and most third party tools have issues working as advertised. Looks like many useful tools were cut from the Whitbey. Am I missing something, but if I recall correctly,  there was an RSS generation control also that was  cut? Am I right or wrong? Cheers, yousaid

  • Anonymous
    September 16, 2008
    The comment has been removed

  • Anonymous
    February 08, 2009
    I've tried out the GenerateImage control and it is certainly something that should be in the next version of .NET.  [Actually, I think that it should have been in 2.0]  However, I am finding it tricky to set the parameters programatically. For example, this works fine: <Parameters>    <cc1:ImageParameter Name="ID" Value="1" /> </Parameters> But in the .ashx file this does NOT work: string qsID = HttpContext.Current.Request.QueryString["id"].ToString(); parameters.Add("ID", qsID); Thus, I would be grateful for any info on how to set the NameValueCollection parameters. Thanks, Mark Beatty

  • Anonymous
    October 21, 2009
    Try this: imageObject.Parameters.Add(new Microsoft.Web.ImageParameter { Name = "ID", Value = qsID });