Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.