Is there a .Net library to create Css sprites, from a list of Image objects, or image files?
I am optimizing the images of a website using css sprites, but it is very difficult to do it all the times, because styles change, images change, css changes, everything changes with time. I wish to integrate an image optimizer algorithm into our VisualStudio add-in, but I need to make a lib to do it, or find an already existing lib that does it.
I need something like this:
- input: list of images (e.g. list of Image objects, list of 开发者_如何转开发image files, whatever...)
- output: css-file + single-image-file
Please, I need suggestions on how to automate this process as much as possible.
By the way, it could be an external program, it does not need to be a library, but I prefer a library. Also it does not need to be in C# or VB or anything... but it must be something that I can call from C# code, but again I prefer that it is a .Net assembly or C# code.
Thanks.
I believe that the Sprite & Image Optimization Framework does just that.
I recently embarked on a similar task and figured I'd share my findings for future reference. These projects also look like viable options that can be integrated or customized as needed:
- http://spritegenerator.codeplex.com/
- http://www.codeproject.com/KB/aspnet/cssspritegenerator.aspx
- http://requestreduce.com/
SpriteGenerator appears to focus on efficient image tiling and generates the needed css and related files.
CssSpriteGenerator and RequestReduce attempt to take the headache of the process by plugging into the request pipeline in your Asp.net website to evaluate your non-optimized content and magically create and remap to the optimized output that your traditional css sprite efforts would have produced. Both of these tools can expand the scope of optimization beyond just image sprites but RequestReduce appears to do it natively.
SpriteGenerator is the least far reaching of the solutions and seems to comes closest to the scope of the original request. It doesn't support the concept of saving or loading of a previous config but that's an easy enough customization and the source is readily available.
If however you land on this page after searching Google and are considering options for automatic sprite generation on your asp.net webserver, then RequestReduce looks like the current best bet as it accomplishes the task, is used on high traffic Microsoft sites(and thus likely to improve over time) and runs the gamut of page optimization techniques.
精彩评论