blog

How-to optimize JPEG images for websites

Even if internet connections becoming faster and faster, it’s still important to keep your website as fast as possible. One of the “slow” parts of your website are the images. In this article we show several ways to compress photos and JPEG images for your website.

How to compress photos?

If you build your website, you should compress your photos, banners and most other web elements. Your favorite image editor should have some function to down-size your images. For this article we compare 4 ways to compress our example photo (original file-size 393KB):

Adobe Photoshop

If you use the “Save for web…” function it’s possible to create a web optimized version from your image that is small enough and has a quality which is good enough for your website. In our example we used the preset “High Quality” which is equal to 60% quality. The result is a smaller file with a file-size of 95KB.

Adobe Fireworks

Fireworks is my favorite web image editor because of the unique feature to have bitmap and vector elements in a single file. We did an export with 80% quality and the compressed version has a file-size of 85KB.

GIMP (free Image Editor)

Both Adobe products are not free and are only available for Windows or Mac. If you need a free editor you should try Gimp, an Image editor which many functions like the other commercial products mentioned before. The editor has also a “Safe for web” function and we used and 86% quality for our export file which becomes a size of 87KB. If you use GIMP to down-size your photos from your digital camera you should check the option “Strip EXIF”, removing the photo’s meta data will make the file smaller for another ~10KB.

ImageMagick (command line tools)

Our last option is ImageMagick a Linux command line tool. Using the following command the file is down-sized using an 80% quality (file size after conversion is 89KB): convert original_100.jpg -quality 80 imagemagick_80.jpg Sure this method works different from the other methods but the good point is that you can use this code in your PHP scripts or just from the command line of your web server.

Original image and compressed copies

Check the images below and note that the quality for the compressed images (file 2-5) is very similar.

The results after the photo compression is very similar and the file size is between 85KB (fireworks) and 95KB (Photoshop). If you’re looking to down-size another 5-10%, you should try Smush.it a free service from Yahoo. They offer a tool which is able to optimize your images for 5-10% smaller file size without to lower the grade of quality.

Optimize your JPEG images with ImageMagick and PHP

If you need to optimize the images for your existing website, the following PHP code might be useful:

Just enter the path to the the directory you like to optimize safe the code as a PHP script and execute the file from the command line of browser. Using this PHP script, only the photos (JPEG files) are getting compressed. Compress your photos to make them load faster, but be careful don’t compress your images too much.

Related posts

20 Replies to “How-to optimize JPEG images for websites
  1. Sculptra 含有由含有源於植物果酸的 PLLA 聚左乳酸(poly-L-lactic acid),它能促進天然膠原蛋白大量增生,令容顏重現年輕,一個療程的效果能持續逾2年。Sculptra 乃全球唯一獲美國食物及藥物管理局(美國FDA)認可的PLLA聚左乳酸美容品牌。Sculptra 塑然雅會被人體自然分解吸收,同時促進天然膠原蛋白再生1。療程效果可以漸進地給你更富清新朝氣的容頻,效果自然,更不會影響面部表情。SCULPTRA 塑然雅 Sculptra 由含有源於植物果酸的PLLA聚左乳酸(poly-L-lactic acid),它可以被新陳代謝成二氧化碳及水,最終自體內排出。PLLA聚左乳酸早已被廣泛應用於醫療用品超過30年,自2009年起 Sculptra 及全球唯一獲美國FDA認可的PLLA聚左乳酸美容醫學品牌。Sculptra ® 塑然雅能促進天然膠原蛋白大量增生1,改善皺紋,令容顏重現年輕。全球唯一獲美國FDA認可PLLA聚左乳酸。臨床研究證實於3個月間,肌膚的膠原蛋白密度 顯著增加67%2。療程效果能持續愈2年3。主要成份PLLA聚左乳酸源於植物果酸,醫學界廣泛使用超過30年。

    http://cosmedicbook.com/treatments/info/Laser-facial

  2. 激光是單一波段的光能 , 在同一時間發射 , 光線能量較為集中 , 能深入皮膚打擊患處之異常色素或血管 , 溫和地刺激皮膚內的骨膠原更生, 新生的骨膠原令您的膚質光澤柔嫩 , 煥然一新 , 抗老效果顯著。有效治療色斑(雀斑 , 太陽斑 , 咖啡斑 , 太田痣 , 紋身) , 血管問題 (葡萄色斑 , 微絲血管擴張) , 膚色不均 , 皮膚鬆弛 , 毛孔粗大 治療後皮膚會出現短暫的紅腫 , 要注意防曬及遵照醫生指示護理皮膚

    http://cosmedicbook.com/treatments/info/Ultra-V-Lift-4D埋線

  3. A lot of thanks for each of your hard work on this blog. My mum takes pleasure in making time for investigation and it’s easy to see why. I hear all of the powerful tactic you provide practical items on this web blog and attract response from other individuals on the issue so our favorite princess is without a doubt discovering so much. Take advantage of the rest of the year. You’re carrying out a great job.

  4. I simply wanted to thank you so much yet again. I do not know the things I would’ve carried out in the absence of these methods documented by you about that area. This has been a very intimidating problem in my position, however , being able to view this specialised approach you processed it took me to jump with happiness. I will be happy for the assistance and as well , have high hopes you know what a great job you’re accomplishing training people today using a blog. More than likely you haven’t met any of us.

  5. I together with my guys have already been reading through the excellent tips and hints on the website then instantly I had a horrible feeling I never thanked the blog owner for those strategies. The people happened to be as a result stimulated to see all of them and have now absolutely been tapping into those things. Thanks for indeed being quite kind and also for getting this kind of tremendous areas most people are really wanting to understand about. My very own sincere regret for not expressing appreciation to you sooner.

  6. I must express my thanks to the writer just for bailing me out of this particular incident. After surfing around through the online world and obtaining advice that were not helpful, I believed my entire life was over. Existing without the approaches to the difficulties you have fixed by way of the post is a serious case, and ones that could have adversely damaged my entire career if I had not noticed the website. Your actual capability and kindness in taking care of all the details was important. I don’t know what I would have done if I had not encountered such a stuff like this. I can also now look ahead to my future. Thank you very much for your reliable and effective help. I won’t be reluctant to recommend the website to any person who desires tips on this area.

  7. I together with my buddies appeared to be checking out the good guides found on your web blog and immediately I had a terrible feeling I had not expressed respect to the web blog owner for those techniques. The young men are actually as a result stimulated to see them and already have surely been having fun with those things. Many thanks for simply being well thoughtful as well as for using variety of smart topics most people are really desirous to be aware of. Our own honest regret for not expressing appreciation to sooner.

  8. Needed to create you this little bit of word to be able to thank you so much the moment again over the splendid views you have discussed above. It is certainly wonderfully generous of you to convey openly all many of us would have offered for sale as an e book to end up making some money on their own, most notably since you might have done it if you desired. Those guidelines likewise acted as a easy way to fully grasp that other people online have a similar keenness much like my personal own to learn lots more in respect of this problem. I am sure there are some more enjoyable situations ahead for individuals who looked over your blog post.

  9. Thank you a lot for giving everyone such a nice opportunity to read from here. It is usually so lovely plus jam-packed with a good time for me and my office fellow workers to search your web site on the least three times per week to see the latest stuff you have got. And definitely, I’m also always motivated concerning the cool points served by you. Selected 2 tips in this posting are completely the most impressive we have all had.

  10. I precisely wanted to appreciate you once again. I do not know the things I would have taken care of in the absence of these hints provided by you over this concern. It became a very frustrating scenario for me personally, but understanding this specialised form you treated it took me to leap with joy. I’m just grateful for your information and have high hopes you are aware of a powerful job you happen to be doing educating the mediocre ones through your webpage. I am sure you’ve never come across any of us.

  11. I in addition to my pals ended up looking through the nice helpful hints found on your web site and then before long I got an awful feeling I had not thanked the web site owner for those strategies. Those people happened to be for that reason passionate to read them and already have sincerely been making the most of those things. Thanks for actually being very accommodating and also for figuring out certain quality subject matter most people are really desirous to discover. My sincere apologies for not expressing appreciation to earlier.

  12. I want to show some appreciation to this writer for rescuing me from such a trouble. Right after checking throughout the world-wide-web and finding basics that were not productive, I believed my life was gone. Living minus the solutions to the difficulties you’ve resolved by way of the blog post is a crucial case, and those which might have badly damaged my entire career if I hadn’t noticed your blog. Your actual ability and kindness in playing with every aspect was invaluable. I don’t know what I would have done if I hadn’t discovered such a point like this. I’m able to at this moment look ahead to my future. Thanks for your time very much for this expert and effective guide. I won’t be reluctant to suggest your blog post to anyone who should get guidelines on this matter.

  13. I have to express my passion for your generosity in support of men and women that need help with this important concept. Your very own dedication to getting the solution all over appeared to be astonishingly productive and have in most cases helped guys and women just like me to achieve their dreams. Your own helpful tips and hints means a great deal a person like me and especially to my mates. Many thanks; from all of us.

  14. Thanks for all of the labor on this web site. My mum delights in participating in internet research and it’s really obvious why. Many of us know all about the dynamic method you provide valuable suggestions through this web blog and even increase participation from some others on that topic then our own princess is undoubtedly becoming educated a lot of things. Have fun with the rest of the new year. You have been conducting a good job.

Leave a Reply