Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I havent decided on a technology yet but i wanted to ask. BMP images are large, i compressed a 3mb image to 50k. Browsers can decode gzip text, so would it be possible to gzip bmp on my server and have the user request mysite.com/images/test.bmp and have it decompress my gzip bmp on the other side so the user doesnt notice a difference?

share|improve this question
    
Why do you want to use BMP images on the server, instead of a more modern format like PNG? –  Peter Hilton May 31 '09 at 9:52
add comment

6 Answers

If possible, use PNG as image format. It's the defacto standard for lossless image compression and will probably surpass the compression level achieved by merely gziping bitmaps.

If you need to use BMP because of dependencies from legacy systems, you can try using the output compression methods available in your webserver, e.g. see mod_deflate for Apache. Wireshark can be especially helpful in testing/debugging such setups.

share|improve this answer
add comment

Gzip before sending. Good webservers (Apache, NGINX, and probably lighttpd) all support having a 'image.bmp.gz' on disk, and sending that instead of 'image.bmp' if the browser supports it. Add this to .htaccess in apache: "AddEncoding x-gzip .gz". I fraggin' hate it when people think compressing files on the fly really saves anything.

Really, you should just use PNGs, since they are gzipped BMPs, sometimes with an alpha channel thrown in as well. The format was created to make people stop using GIFs, who's compression algorithm was, and might still be under patent by Unisys. Oh, and a bmp.gz and png will compress equally well.

share|improve this answer
    
+1. I cant use PNG i have to have the original file available (IE the user must get a BMP back if he wants instead of a png). On upload i compress bmp bc i know it will compress well. I just didnt know how to allow /files/image.bitmap to use the .gz version on server. Thanks for your answer. –  acidzombie24 Aug 10 '09 at 22:17
add comment

With using apache and mod_gzip or mod_deflate, if the client accepts gzipped content, apache will serve gzipped file. Even you can add a file.gz in pair with the original file helping out apache with gzipping.

If you do not want to host original files, normally apache will answer with 404 for a .bmp request. (You do not have that file do you?). But with the help of apache mod_rewrite you can add some rewrite rules to serve gzipped bmp instead of returning a 404 Error.

Sample (and untested) rewrite rules:

RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule ^(.*).bmp$ $1.bmp.gz
share|improve this answer
add comment

I am not sure if my test is representative: I compressed a local bmp file with gzip and tried to open it on Mac OS X with Safari and Firefox: it does not work (with or without .gz extension).

share|improve this answer
    
HTTP has gzip compression on transport level. Browsers don't emulate that with file:// protocol. –  porneL May 30 '09 at 23:46
    
Does it mean that the file transmited on the network is uncompressed? The benefit would then be only on server storage space. –  mouviciel May 31 '09 at 8:46
    
No it does mean that the file is stored uncompressed on the server and will be compressed by the server just before transmission, the browser will then decompress it just before showing it (or rather downloading in case of BMP) –  Server Horror Jun 12 '09 at 7:12
add comment

From mod_gzip's sourceforge.net page:

"mod_gzip is an Internet Content Acceleration module for the popular Apache Web Server. It compresses the contents delivered to the client. There is no need to install any additional software on the client!"

I think it basically compresses everything it sends with the exception of anything which is already compressed, such as JPGs or GIFs, etc. I think it is often enabled in default Apache installations, but you can Google for docs.

share|improve this answer
add comment

Hmm, interestingly ziproxy http://ziproxy.sourceforge.net/ seems to gzip "text likes" and convert images to jpeg.

I can see possible issues zipping bmps - might not compress well, or fast, for example. Certainly conversion to a.n.other format is more browser-compatible. As suggested, PNG will support everything you need, jpeg might do if you can hack lossy compression in your application.

Don't quote me on this but i am fairly sure you could automate this and convert on-the-fly. I would be inclined to run a (nightly?) job that converts bmps (use "convert" if you're on unix) and rewrites links.

Give us a bit more "why" and we may get a better "how" :)

Where are your bmps coming from, how are they being serverd, what platform, etc.?

share|improve this answer
add comment

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.