PDA

View Full Version : The 3 web image formats: JPG, GIF & PNG



Darren Null
09-27-2009, 9:04 PM
JPG
This is used for absolutely everything on the internet. It is the absolute best way of delivering photograph-style pictures in the least filesize. As an example, the attachment alaskanaa.jpg is 104Kb. The same image in a BMP is 747Kb; a TIF 770Kb and a PNG 369Kb.

Disadvantages:
JPG is a lossy format. It gains you the stupendous filesize savings by literally throwing away information that you won't notice, with a bit of luck. When you save an image as a JPG, you usually get a sliding bar with the amount of compression to use. If you use too much, you get artifacts alaskanab.jpg (bits that were not part of the original image) and your image will look awful; particularly around hard edges in the image. Also, JPGs get very cranky if you try to get them bigger than 30,000 pixels in any dimension.

You might not know this:
You can save clipping paths as part of your JPG. So you can open it in Photoshop (for example) and -if some kind soul has clipped the subject out for you- you can easily extract the bit you need from the image.

GIF
...is an odd one. It uses a limited palette of colours (up to 256) which is an advantage and a disadvantage, depending upon whether you use it properly. Gif also has transparency, but the GIF transparency isn't really worth using these days (see PNG). Used properly -if you have an image with few colours in it, like a logo- you can gain significant savings in filesize over even a JPG. Example gpl.gif at 6.6Kb isn't significantly different to gpl.jpg, weighing in at 33.4Kb.

Disadvantages:
Gif won't win with a photograph though. You either have to use all 256 colours, in which case the file will be bigger than a JPG; or you don't use enough, and end up with the '80s porn look': alaskanaa.gif.

You might not know this:
Because of the limited colour palette, you can use the GIF format to generate patterns for low-fi projects like cross-stitch and mosaics. Let's say you want an elephant picture on the bottom of your pool.
1) Find your image, work out how many tiles will be needed for your pool and resize accordingly. elephant1.jpg. I can get 500x397 tiles in the bottom of my pool.
2) Work out how many colours you want to work with. I reckon my elephant looks OK in 4 colours, so I save it as a GIF using 4 colours. elephant2.gif
2a) Whilst saving as a gif; screen capture the colour table (printscreen button; then FILE --> NEW --> EDIT --> PASTE in the graphics editor that you have open because you're saving an elephant picture in it). elephant3.jpg. Print that out, because that's what you take to the shops to match up the colour of your tiles/wool/whatever
3) Zoom in on your elephant picture and you have a map of where your tiles/stitches should be. elephant4.gif- next post. There are a variety of ways of dealing with your map now: You can attempt to synchronise printing to graph paper; you can print out the image REALLY BIG over lots of sheets of paper and mark the coordinates in by hand. What I have done in the past is to dice the image into chunks (square metre of pool bottom, say), import it into coreldraw and put a labelled grid over it. How to do that is a little beyond the scope of what was intended as a simple tutorial.

Darren Null
09-27-2009, 9:43 PM
PNG
PNG is a relative newcomer to the scene. It's a lossless format. There's compression there to reduce filesize, but none of your image gets sacrificed. PNGs can't compete with JPG for filesize; but you don't get strange colours or artefacts cropping up. The most lovely bit about png, though is alpha transparency. This means that any given pixel can have a variable amount of transparency, and this is important because of a graphical process called feathering. Let's say you have black text on a white background. If you just go straight from black to white any lines that don't run straight horizontally or vertically are jagged. Feathering, then, is a way of adding pixels (grey in this case, but a compromise between the 2 colours) that make you imagine the curves and diagonals more as they were intended. feather1.gif and feather2.gif are a demonstration and closeup of feathering in action.
So what does this mean for transparency? Well gif transparency is either on or off, so you have to feather for a specific background colour. If you change your website colour, you have to change all your GIF images. I'll feather a gif image with the wrong background colour to demonstrate meerkat1.gif. If you don't feather, of course, you get jagged edges.
PNG, on the other hand, can feather with transparency. So instead of a 'real' grey colour; it's using black all the time (in the case of the text), but with variable transparency. What this means, is that you can have a PNG graphic with transparency and drop it anywhere. Any colour, textured background...doesn't matter. It'll look the same and there's no jagged edges. meerkat2.png. EDIT: The white border around the image is due to the board's thumbnail thingy, not the graphic.

Disadvantages:
Bit heavy on filesize.

Here endeth the lesson. (In 2 posts because I hit the attachment limit)

Darren Null
09-27-2009, 9:49 PM
Oh yeah, on the subject of web graphics; the SMC logo is dire (sorry to offend the creator, but it is. Really). So I knocked this up while I was playing in photoshop. Same size and format as the existing, so it'll drop straight in if you want it.

Doug Griffith
09-27-2009, 11:38 PM
Good and thorough explanation Darren! To sum it up, .jpgs are best for photographs because of the high compression and resulting small file sizes. .gifs are best for logos and graphics where a hex color is specified for the background. .pngs are becoming quite compatible these days so are good for logos and graphics on non-solid backgrounds.

As for applying this to the laser world, pngs saved as 24 bit will produce far better engraving results than a .jpg or .gif. As Darren pointed out, .jpgs are lossy and .gifs have a restricted color palette. .pngs saved as 8 bit have a restricted color palette as well.

So if you customer has to email you a bitmap image, ask for a 24 bit .png. Or ask for a greyscale tiff that is compressed as a .zip.

Then there's resolution and color space to worry about.

Cheers

Darren Null
09-28-2009, 8:27 AM
Thanks for pointing that out Doug- All the .PNG references were to PNG-24.

If one of the above 3 bitmap formats won't do it for you, then TIF probably will. As far as colour space goes...since we're talking about bitmaps; you'll probably get sRGB (from nearly everybody's camera) or AdobeRGB. It only gets complicated when printers send you the file.

Bill Cunningham
10-01-2009, 10:18 PM
Heres a link I send to my customers quite often..

The Evils of Using .jpg files (http://www.unleash.com/articles/eviljpeg/index.asp)

Larry Bratton
10-02-2009, 5:15 PM
Heres a link I send to my customers quite often..

The Evils of Using .jpg files (http://www.unleash.com/articles/eviljpeg/index.asp)
Indeed..I remember sitting in Foster Coburn's Corel Bootcamp classroom in Cave Creek, Az and learning about jpg being a lossy format..that has been about 15 years ago and not much has changed. I use tiff and eps mostly for print and laser work. I only use jpgs for e-mail and internet or things that are to be mostly just viewed on a computer screen. Also remember that a computer screen can't use more than 72dpi, so anything above that for viewing is a waste of space.