Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .pgm image file that I'd like to display on my apache webserver. Right now when I try to display it, it fails. Is there a way to configure apache so that I can display it successfully on a browser? I've tried searching but I haven't found anything useful.

If not, what can I use to convert the .pgm image file into another format, say .jpg, and then display the .jpg image?

share|improve this question
up vote 0 down vote accepted

Whether it will render ultimately depends on the browser, however I believe the "magic sauce" you are missing to make it work from the server side is that you need to specify the mime type.

There are a few ways to do this but generally Apache reads the file /etc/mime.types You need to ensure the line "image/x-portable-graymap pgm" is added to this file so it serves the image up correctly.

The alternative would be some kind of script and cgi to convert it using the netpbm library or something like that. (I've not used it, but it looks like you can use pgmtoppn and then ppntopng to convert a file to a jpg)

share|improve this answer
Adding image/x-portable-graymap pgm to /etc/mime.types doesn't work. If possible, I'd really much prefer this over having to convert the image to another format. – Andrew Nov 29 '13 at 8:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .