dynamic image (png) file

G

Guest

I've recently seen a couple of sites that have dynamically generated .png
files on them and I'm wondering how to do it in c#, or if it's a server side
thing. Here are a couple of links:
http://www.serverspy.net/bin/hmon/12.183.157.40:27015/0/image.png
http://miniprofile.xfire.com/gaspar.png

Both of these images are real-time/dynamically generated, but they have a
..png extension. I understand how to create/manipulate and render images in a
..aspx page, but the image tag has to point to an .aspx page address to work.
How are these images being generated with a .png extension?

My first guess would be that the mapping for the .png extension is being
changed ont the server to use whatever scripting language the site is
supported. Since the images are generated real-time I'd rule out saving temp
files for display purposes.

Any ideas/help will be appreciated.

Thanks.
 
T

Teemu Keiski

My first guess would be that the mapping for the .png extension is being
changed ont the server to use whatever scripting language the site is
supported. Since the images are generated real-time I'd rule out saving
temp
files for display purposes.

Exactly. For example with ASP.NET, .png extension could be mapped first in
IIS to ASP.NET ISAPI, so that ASP.NET can process those requests and then
yet, it could be a custom HTTP handler (a page or a custom handler) to
process the request at ASP.NET side.

There could be temp files with this approach (depends howe the HTTP handler
works) but not necessarily, it could also use output caching to ease the
request processing burden.
 
S

Sean M

(comments inline)

Phil said:
I've recently seen a couple of sites that have dynamically generated .png
files on them and I'm wondering how to do it in c#, or if it's a server side
thing. Here are a couple of links:
http://www.serverspy.net/bin/hmon/12.183.157.40:27015/0/image.png
http://miniprofile.xfire.com/gaspar.png

Neat, isn't it. :)
Both of these images are real-time/dynamically generated, but they have a
.png extension. I understand how to create/manipulate and render images in a
.aspx page, but the image tag has to point to an .aspx page address to work.
How are these images being generated with a .png extension?

It is possible to write HTTP protocol handlers in C# or other .NET languages
and then assign a handler for the .png extension for the individual web
application in the IIS settings dialogues.
My first guess would be that the mapping for the .png extension is being
changed ont the server to use whatever scripting language the site is
supported. Since the images are generated real-time I'd rule out saving temp
files for display purposes.

A primitive way of writing it would be to save it as a temp file, but if you
have drawn something programmatically, it is usually simple to stick it in a
MemoryStream object and attach it to the response inside the protocol
handler.

-- Sean M, who admittedly has not tried this himself so correct me if I'm
off base on this
 
G

Guest

Thanks for the help ;).

I'm not familiar with http handlers. Is this something that would have to
also be implemented through IIS, as well as code? I'm currently hosting
through a third party hosting company and I'm pretty sure I won't be able to
change IIS mappings/settings.

Thanks!
 
T

Teemu Keiski

With ASP.NET , yes, it would need a mapping in IIS because IIS is the first
one to direct the request to the correct place for processing. This is a
different case with IIS 7, but that won't help here for a few years. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top