Tag Archives: file size

JPG, GIF, or PNG: This Is The Question

jpggifpng
Most beginning web designers have some difficulty with file formats, especially concerning images–I know I certainly did when I was starting out. There are three separate formats for images, and it’s hard to know which format is the best for saving image files that you’re going to display on your website, either as part of your layout or as part of your content. You don’t want the images to take two days to load, but you don’t want them to look like you used them for toilet paper, either. What is a web designer to do?

JPG: Best for Photographs, Not for Graphics

When I first started out, I read a few tutorials here and there about image saving, but I really took to the JPEG file format because it saved my images in such a small kilobyte size, which was and still is important to me. I was very impressed with how JPEG compression packed the image into such a small space that it transmitted well even over a dialup connection, so I began using .jpg format for all of my layout images, content, everything. It’s sort of the same principle as admiring someone who’s managed to pack a ton of stuff into their suitcase–you sit there wondering “How’d they do that?” Little did I know how much JPEG had left out of my images–like people leaving half their outfits at home to save space.

I don’t claim to know how JPEG compression works, but for the most part, it tends to leave a good bit of information out of your image, especially when you save it as a JPEG and choose “Low” or “Medium” quality. The blown-up versions of the two images at the first of this section show you what results from saving an image at “Low” or “Medium” JPG quality:


From left to right: Low: 2.70 KB; Medium: 3.74 KB

As I’ve heard it described, JPEG, especially low- or medium-quality JPG, is a “lossy” format–it’s like your image’s “suitcase” has a hole in the bottom. It sure is lighter when you get to your destination, but there’s a reason for that–the style of compression leaves out some of your image’s pixels to make the file smaller. The JPG file format doesn’t work very well for layout images and small icons because it tries to make up for all the pixels it left out, leaving your image rather pockmarked and subtly polka-dotted with oddly-colored pixels. Once you go up the quality scale, however, you get much better results, but you’re going to have to have a bigger file size, as shown below:


From left to right: High: 5.99 KB; Very High: 8.72 KB; Maximum: 13.7 KB

The blown-up versions below show how much better the image is constructed:


From left to right: High Quality, Very High Quality


Maximum Quality

But do not despair–JPG is absolutely wonderful for photographs, for some odd reason. I’ve taken to using JPG sparingly or not at all in my layout designs unless the layout features a full-color photograph or two, and if I have lots of pictures, I’ll use JPG to compress them without losing too much. (I find that JPG “Very High” quality blends the best of both worlds–smaller file size and good-looking product.)

GIF: Best For Icons and Little Graphics

I used to never touch GIF files except to make random little animations. I thought the file format was overly bloated–certainly its files were usually twice as big as JPG files of the same item. Little did I know, the format was actually going to prove quite useful to me! It may not be as good as JPG at compressing files, but it is great for making your layout tick.

As you can see below, there are four different sub-formats within the GIF format type. Again, I don’t claim to know how each of these works, but I have noticed that “Perceptual” and “Selective” generally turn out the best results; “Adaptive” and “Restrictive (Web)” make me die a little inside, as a web designer, because of the loss of colors. These formats generally correspond to how many colors make up the palette that the image is created from; “Restrictive (Web)” pulls from the smallest palette.


From left to right: Perceptual: 5.77 KB; Selective: 5.75 KB; Adaptive: 5.83 KB; Restrictive (Web): 2.49 KB

For certain, GIF files are terrible when it comes to full-color photographs. But they are wonderful for creating tiny layout graphics that would have otherwise been mistreated by the wrong end of a JPG format. I have used the GIF file format to make some of my first semi-transparent images, as well as the well-beloved transparent “spacer” image. Also, I still use GIF format here and there to make small but readable icons, as well as some of the infographics for my articles.

PNG: Best for Big and Detailed Graphics

Now we come to the file format that is my favorite for web designs as of late. It used to be that I couldn’t even open PNG files on my computer at all–it would load an error message if I went to a site that had PNG files as part of its content or layout. But that was in the dinosaur days of design, I suppose–nowadays, PNG is the great beautifier of the Internet, doing well at saving fully-colored graphics with an even smaller file size than GIF usually can.


PNG-8: 5.43 KB

This image is exactly the same as the GIF image, but PNG saved it with a few less bytes than even the smallest of the quality GIFs (excepting “Restrictive”, which is tiny file size at the cost of a good-looking image). Again, not sure why there is this difference, but I like it–anywhere I can save on file size without losing quality is great for creating a fast-loading and good-looking website.

It also seems to me that PNG does a better job of maintaining the colors I use in my designs. Sometimes, when I save a layout’s pieces in JPG or GIF (and especially GIF for some reason), the colors in the image change, just slightly, just enough to throw off my CSS color codes and make me have to go back and resample the image for my colors. Now, with PNG, I find myself more able to go straight from Photoshop to Notepad to code, and not ever have to refer back to my image for colors, because they’re right on target!

As for using PNG-8 versus PNG-24, I find that PNG-8 does most of what I need it to do. However, if my image just HAS to be highest quality or has transparency in it, I choose PNG-24–it may add half again to the kilobyte size, but it produces the smoothest-looking image. Compare the two below:


From left to right: PNG-8: 5.43 KB; PNG-24: 11.7 KB

Lastly, PNG seems to be better than GIF at handling transparency and not having strange chippy pixels on the sides of the supposedly-“transparent” image or icon. See evidence of this goodness below:


From left to right: Perceptual GIF, Selective GIF, Adaptive GIF, Restrictive GIF


From left to right:  PNG-8, PNG-24

Summary:

If you’re not sure what kind of file format your images need to be in, remember that JPGs are best for photographs, GIFs are best for simple web graphics (icons and the like), and PNGs are best for detailed web graphics (big layout pieces). These simple tips will save you tons of time working on and saving your images!

Fast Loading Times: A Personal Trademark

fastloadingtimes
Since I began designing and coding websites in the fall of 2003, much has changed on the Internet. Websites can now include more scripts, plugins, and images; websites are just simply BIGGER than before high-speed Internet and social media became more widespread. But I still monitor the file sizes for my layout graphics, post images, and Web pages, because I still like my pages to load quickly, and I still consider loading speed to be important.

Why I Concern Myself with Loading Speed

I suppose part of my design style got stuck in the pre-high-speed-Internet era, since it has only been since winter 2013 that I finally could get any kind of high-speed Internet at home. But if we designers and developers take the time to learn how to make our sites load quickly, even on slow connections, that makes it more likely that our content will be read, and hopefully that visitors will return–something we all want.

For instance, many people now take in Web content through mobile connections, which can be slow depending on individual data plans and signal strength in the area. Why choke that slower connection with unnecessary “junk” on our layouts, or in our files? Why not polish up our sites so that even on a weaker strength mobile connection, our content still loads quickly?

Ways To Optimize Loading Speeds

#1: Keep images to a minimum.

One of the main ways I streamline a page is to edit down my images as much as possible, including just enough visual detail without going overboard on file size and complexity. With mobile web usage on the rise and flat design theory currently in vogue, many other designers are moving toward this “less is more” concept. Many things which previously could only be achieved with images can now be accomplished with HTML special characters, CSS styling, or icon fonts, for instance. (And there are quite a few other CSS3 and HTML5 tricks, which can reduce or even eliminate the need for images altogether!)

#2: Divide up the content into smaller pages.

Another way I streamline is to divide long pages up into smaller pages and make a sub-section out of them. Yes, that means more links to click or tap, but it also means your users don’t have to load huge pages of material and waste time scrolling around trying to find what they want. Just make sure you provide clear navigation paths, like breadcrumb navigation, so that users can easily find their way around your site’s content!

#3: Compress images.

Compressing your images may seem like an unnecessary step, but when you’re trying to save kilobytes (or even megabytes) wherever possible, this can REALLY help! Choosing the right type of image compression, however, is key. (If you’ve ever tried to save something as a Web-Color-Restricted GIF file, you’ll know what I mean by a “grainy GIF.” Ugh, gives me nightmares.) See my post about JPG, GIF, or PNG file types to see more about which compression style is best for the type of image you’re making.

Summary

With just a few simple changes to the way we construct our pages, we can make our sites load super-quick on just about any connection speed and device. It’s worth the time we spend behind the scenes so that our users have a much better experience visiting the fruits of our efforts!