I'm using C to develop a dynamic image set with GD, and am having problems with the output of the image. The source is simple right now so that I can just get the stupid thing working. The provided code below compiles without error or problem (using gcc -Wall -lgd testimage.c -o testimage). When I run it from the command line, the output appears as it should (the content type shows up and then the PNG header and then PNG data), but when I load it in a browser, it doesn't work.
Firefox keeps telling me "You have chosen to open 'testimage' which is an 'application/octet-stream'
. If I embed the image in HTML code using an <IMG> tag, I just get the broken image thing. IE will not display it either. I must be missing something.
Any ideas why it's not working?
im = gdImageCreate(64, 64);
black = gdImageColorAllocate(im, 0, 0, 0);
white = gdImageColorAllocate(im, 255, 255, 255);
gdImageRectangle(im, 0, 0, 63, 63, black);
gdImageLine(im, 0, 0, 63, 63, white);