A Web Design Community curated by Chris Coyier

IE Fix: Bicubic Scaling for Images

By: Chris Coyier on 3/17/2009

Devthought had a little CSS tip the other day that is definitely worth repeating. It’s not new, it’s just an important little trick to know.

And here it is:

img { -ms-interpolation-mode: bicubic; }

If you use width or height tags to resize images in your markup, IE will ensure they look incredibly awful unless you use this little snippet. In general, resizing images in the browser isn’t recommended, but of course there are always exceptions.

55 Responses

  1. Tim wright says:

    That’s a great tip, Idpnt think ive ever seen an ms vendor extension used before

  2. Ryk says:

    heard of bicubic resampling before, never realised IE could do it! thnx!

  3. Ken says:

    oh nice, great little tip!

  4. dario-g says:

    Rule no 1. Do not scale images in browser! :)

  5. Steve says:

    This is just AWESOME!

  6. hunter says:

    “but of course there are always exceptions.”

    what would one of those be?

    • Tim Wright says:

      There’s a lot of gray area when doing client work through a cms, especially with the client who just doesn’t “get it” or understand how to resize images/the benefits (no matter how much education they go through).

      It’s useful when you’re trying to not break the design. Then you can go back and fix the problem without any shocking “my web site is broken!” client freak-outs

    • Josh N. says:

      It helps when you need several sized thumbnails of an image and, because of the CMS you are using, you don’t want to create and manage 5 different copies of the same image. You can scale the thumbnail and have one image download for all instances of that image at slightly different sizes.

      You certainly don’t want to have a high-resolution image squished down, but it does save bandwidth and server calls to reuse small images.

    • Richard says:

      Text resizing.

      Using EM mesurements for images. In one case I’m working on now I have to create a text resizer and the images need to scale with the rest of the document.

  7. Thanks. That is very useful information. I’ve bookmarked this article and tweeted it.

  8. aravind says:

    Thanks a million Chris..
    Never knew such a trick exists..

  9. Johnb says:

    Thanks. This would be useful in a gallery… you could get away with uploading only the large version of the image, even for the thumbnail!

  10. Matt says:

    I would really like to know who at Microsoft thought this was a sensible default…

  11. Ro says:

    I actually spent about half a day a few weeks back trying to achieve ‘smoother scaling in IE’ before I stumbled on that same code – what a revelation. While I agree that images should only be scaled in a browser as a last resort, anyone who uses Imageflow or Galleria should definitely include this little gem. Thanks Chris. (And the article by schill on Code.Flickr)

  12. Never heard of this. Great find, Chris!

  13. Jose de Leon says:

    IE has a capability (under Internet Options) to load a default style-sheet that is applied to every page. If you create a style-sheet file with this rule in it, and set IE to load this file as a default-style sheet, you can enable bicubic scaling for all images in IE.

  14. Josh says:

    Single best CSS trick I’ve gotten from this site.

    Wish I knew about this years ago!

  15. Thanks for the great tip. My business partner has trouble resizing images for her blog post so she just lets Word Press do it. Often they look terrible on IE and I have to clean it up. Not any more! @TraceyHolinka

  16. Matt says:

    That’s a good tip, hopefully IE8 will have that be the default. I can’t imagine why anyone would ever want the current behavior.

  17. Jarryd says:

    I use a CMS at my workplace, so this could become handy as most of our clients probably resize their images via browser scaling. Thanks CC and Devthought :)

  18. YoU says:

    the “-ms-interpolation-mode” seems to be IE 7 only, you will need a AlphaImageLoader Filter for IE 6.

  19. James says:

    What?! I never, ever knew you could do that. Why on earth does IE7 default to not doing this? Is there any legitimate reason why you wouldn’t want an image to scale smoothly?

  20. Chris says:

    Great tip!

  21. Juri says:

    It’s nice, but it wont validate on CSS (W3C CSS Validator)

    • koew says:

      It won’t validate because it’s not valid CSS. It’s proprietary CSS for Internet Explorer. Just like -moz-border-radius is for Firefox.

      If you want to keep your master CSS file clean, put the proprietary CSS in a IE-only stylesheet. Or make a “dirty stylesheet” where all the proprietary styling goes.

  22. Bigismall says:

    Excelent work! Thaks!

  23. Guido says:

    Nice, but: Why would you want to scale an image client-side and not just provide a scaled version from the server?

  24. b00m says:

    I’ve never heard “-ms-interpolation-mode” and I rarely scale images.
    Anywayz…tnx for posting this one. Cheers!

  25. V1 says:

    How about don’t resize images? it gives a performance hit, and its they will always turn up fucked, NO HACKS NEEDED WHOOHOOO

  26. Farid Hadi says:

    I never believed in resizing images in the browser but as Josh N. says in his comment, if it’s the same image with just a slight difference in size it makes sense to do it, saving space and bandwidth.

    Cool little tip. Thanks for sharing!

  27. Excellent! But I noticed it doesn’t work too well or at all in IE6 anybody else noticed this?

  28. José Mota says:

    That’s the best tip I could ever have since some time, since a lot of portuguese still use IE out of ignorance.

    Pretty simple and yet very powerful tip!

  29. Thanks, Great tip.

  30. Curtis says:

    Unfortunately, this seems to cause some performance issues (especially when paired with JavaScript).

    But a good, quick fix when used sparingly.

  31. Paulo72 says:

    Nice one Mr Coyier, really useful when you can’t guarantee all of the images will be resized properly by the client.

    Cheers

  32. Great tip man, thanks for mentioning it!

  33. Max says:

    Great tip, is there a way to do this for PNG?

  34. Jon says:

    JohnB hit the nail on the head… I’m currently creating a javascript gallery that, when viewed on machines without JS enabled, will resize my images via the HTML, so that I can display them nicely within my layout.

    When the javascript kicks in, it just grabs all the images, replaces the size in each image tag and assembles my gallery elsewhere on the page.

    Incredibly handy. Thanks for this tip!

  35. Hutek.info says:

    great tips, so useful for me

  36. Neat tip!

    For a different take on how to integrate large images within websites check out the Inline Multiscale Image Replacement technique:
    http://gasi.ch/blog/inline-multiscale-image-replacement/

    As a nice side-effect, you can publish large images at any size you might have without having to pay a bandwidth premium.

    Even though it is somewhat piggy-backing on Flash it perfectly degrades in situations where Flash is not available.

    As it’s still quite rough around the edges, I’d love to hear your feedback!

    -Daniel

  37. Glook says:

    Good, but not work in IE6.
    Thanx, anyway.

  38. muckluck says:

    It does nothing in my IE6 :(

This comment thread is closed. If you have important information to share, you can always contact me.

* This website may or may not contain any actual CSS or Tricks.