The Silicon Underground
  Welcome to Dave Farquhar's Silicon Underground Tuesday, November 24 2009 @ 06:07 PM CST  
Theme Changer
Change the look of the site by selecting a theme below:

What's New
STORIES
No new stories

COMMENTS last 48 hrs
No new comments

LINKS last 2 wks
No recent new links

Google Ads

User Functions
Username:

Password:

Don't have an account yet? Sign up as a New User

Firefox


Optimizing Web graphics   
Saturday, May 25 2002 @ 02:06 AM CDT
By David L. Farquhar

Gatermann told me about a piece of freeware he found on one of my favorite sites, tinyapps.org, called JPG Cleaner. It strips out the thumbnails and other metadata that editing programs and digital cameras put in your graphics that isn't necessary for your Web browser to render them. Sometimes it saves you 20K, and sometimes it saves you 16 bytes. Still, it's worth doing, because more often than not it saves you something halfway significant.

That's great but I don't want to be tied to Windows, so I went looking for a similar Linux program. There isn't much. All I was able to find was a command-line program, written in 1996, called jpegoptim. I downloaded the source, but didn't have the headers to compile it. I went digging and found that someone built an RPM for it back in 1997, but Red Hat never officially adopted it. I guess it's just too special-purpose. The RPM is floating around, I found it on a Japanese site. If that ever goes away, just do a Google search for jpegoptim-1.1-0.i386.rpm.

I used the Debian utility alien to convert the RPM to a Debian package. It's just a 12K binary, so there's nothing to installing it. So if you prefer SuSE or TurboLinux or Mandrake or Caldera, it'll install just fine for you. And Debian users can convert it, no problem.

Jpegoptim actually goes a step further than JPG Cleaner. Aside from discarding all that metadata in the header, its main claim is that it optimizes the Huffman tables that make up the image data itself, reducing the image in size without affecting its quality at all. The difference varies; I ran it on several megabytes' worth of graphics, and found that on images that still had all those headers, it frequently shaved 20-35K from their size. On images that didn't have all the extra baggage (including some that I'd optimized with JPG Cleaner), it reduced the file size by another 1.5-3 percent. That's not a huge amount, but on a 3K image, that's 40-50 bytes. On a Web page that has lots of small images, those bytes add up. Your modem-based users will notice it.

And Jpegoptim will also let you do the standard JPEG optimization, where you set the file quality to a numeric value between 1 and 100, the higher being the truest to the original. Some image editors don't let you adjust the quality in a very fine-grained manner. I've found that a level of 70 is almost always perfectly acceptable.

So, to try to get something for nothing, change into an image directory and type this:

jpegoptim -t *

And the program will see what it can save you. Don't worry if you get a negative number; if the "optimized" file ends up actually being bigger, it'll discard the results.

To lower the quality and potentially save even more, do this:

jpegoptim -m70 -t *

And once again, it'll tell you what it saves you. (The program always optimizes the Huffman tables, so there's no need to do multiple steps.) Be sure to eyeball the results if you play with quality, and back up the originals.

Commercial programs that claim to do what these programs do cost anywhere from $50 to $100. This program may be obscure, but that's criminal. Go get it and take advantage of it.

Also, don't forget the general rule of file formats. GIF is the most backward-compatible, but it's encumbered by patents and it's limited to 256-color images. It's good for line drawings and cartoons, because it's a lossless format (it only compresses the data, it doesn't change it).

PNG is the successor to GIF, sporting better compression and support for 24-color images. Like GIF, it's lossless, so it's good for line drawings, cartoons, and photographs that require every detail to be preserved. Unfortunately, not all browsers support PNG.

JPEG has the best compression, because it's lossy. That means it looks for details that it can discard to make the image compress better. The problem with this is that when you edit JPEGs, especially if you convert them between formats, you'll run into generation loss. Since JPEG is lossy, line drawings and cartoons generally look really bad in JPEG format. Photographs, which usually have a lot of subtle detail, survive JPEG's onslaught much better. The advantage of JPEG is the file sizes are much smaller. But you should always examine a JPEG before putting it on the Web; blindly compressing your pictures with high compression settings can lead to hideous results. There's not much point in squeezing an image down to 1.5K when the result is something no one wants to look at.

  [ Views: 2153 ]  


Optimizing Web graphics | 4 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
David Huff
Authored by: ImportedComment on Saturday, May 25 2002 @ 11:18 AM CDT
That Japanese website is down (perhaps all of your readers slashdotted it ;) A Google search returns nothing, as does a search on the RPMfind website. Any chance of you posting it somewhere, or emailing it as an attachment ?

[ Reply to This ]

Gatermann
Authored by: ImportedComment on Saturday, May 25 2002 @ 12:27 PM CDT
I had the same luck. I got to the site, but couldn't track the file down. And I had the same luck on google.

[ Reply to This ]

Dave Farquhar
Authored by: ImportedComment on Saturday, May 25 2002 @ 01:26 PM CDT
It's here.

[ Reply to This ]

Dave Farquhar
Authored by: ImportedComment on Wednesday, December 04 2002 @ 02:15 PM CST
Great news: jpegoptim is now in Debian Unstable. This might be the first step to climbing out of obscurity. Ain't open source grand?

[ Reply to This ]

What's Related
  • tinyapps.org
  • JPG Cleaner
  • source
  • Japanese site
  • More by DaveF
  • More from Design

  • Story Options
  • Mail Story to a Friend
  • Printable Story Format


  • Calendar
    November 2009
    SuMoTuWeThFrSa
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    1
    2
    3
    4
    5
    Click on any day to see postings and events for that date.

    Referrals

    Top 10 by Comments
    Story TitleComments
    Cheap laptops from Sotec 253
    An untrustworthy vendor 164
    Upgrading an eMachine 125
    eMachine upgrade advice 99
    Why I dislike Microsoft 51
    Upgrade diary: Gateway G6-400 35
    And we're live 30
    The day after the Columbia 22
    How to pray 22
    CD-ROM troubleshooting under Windows 9x 20

    Top 10 Read
    Story TitleViews
    eMachine upgrade advice 74353
    Upgrading an eMachine 63106
    How to view a blg file in Windows 2000 50661
    Cheap laptops from Sotec 32806
    Upgrade diary: Compaq Presario 7360 20003
    Upgrade diary: Gateway G6-400 19880
    CD-ROM troubleshooting under Windows 9x 15559
    Finding an open-source alternative to Ghost 14300
    Big trouble 13827
    Salary cap? Baseball needs something 11806

    Topics
    Home
    Apache (2)
    Baseball (63)
    Book reviews (2)
    Business (1)
    Christianity (57)
    Cooking (1)
    Copyright (16)
    Curmudgeonry (1)
    Design (7)
    DOS (6)
    Games (4)
    Genealogy (11)
    General (507)
    Hardware (168)
    Health (13)
    Human Interest (9)
    Humor/Satire (19)
    Investing (4)
    Journalism (1)
    Linux (93)
    Macintosh (22)
    Model Building (3)
    Music (33)
    net.culture (40)
    Personal (88)
    Photography (6)
    Politics (3)
    Retro Computing (26)
    Saving money (72)
    Servers and Networking (18)
    Society (49)
    Software (55)
    Spam (13)
    St. Louis (23)
    This weblog (14)
    Toy trains (74)
    Troubleshooting (7)
    Useless Trivia (1)
    Vendors (6)
    Video (21)
    Viruses (12)
    Windows (120)
    Writing (16)

    Older Stories
    Wednesday 30-Sep
  • 401(K) Paperwork (0)

  • Sunday 27-Sep
  • First impressions: HP Mini 110 (1)

  • Saturday 26-Sep
  • Getting more screen real estate in Firefox (0)

  • Wednesday 23-Sep
  • Barfy. (4)

  • Monday 21-Sep
  • Why I quit my job (2)

  • Saturday 12-Sep
  • Slimming down Windows XP for SSDs and nettops (0)

  • Thursday 10-Sep
  • And... bailing out. (3)

  • Friday 04-Sep
  • End of the innocence (0)

  • Monday 31-Aug
  • Installing Windows off USB (1)

  • Friday 21-Aug
  • Diving into real estate (0)

  • Who's Online
    Guest Users: 8

    Syndicate!
    Get your RSS/RDF fix here.

    List of all stories
    Click here for a list of all the entries on this site


    Created this page in 0.98 seconds


     Copyright © 2009 Dave Farquhar's Silicon Underground
     All trademarks and copyrights on this page are owned by their respective owners.

    Powered by GL 1.3.x