Forum Moderators: open

Message Too Old, No Replies

What is the fastest way to have images load

         

website

4:25 am on Mar 30, 2005 (gmt 0)

10+ Year Member



i know there are various image compressions around jpeg, gif, png, and many more... my question is which compression allows the greatest quality with the lowest size, and in general the lowest size. I am assuming that the later belong to a form of the .gif compression. I am no newbie to this, as i have been developing for around 6 years now. I am trying to skinny up my websites as best as i can and i am wondering if there may be any techniques i am unaware of.

also, are there any new types of compressions being developed that may enhance the speed of web page image loading greater than what is currently available?

thank you

tedster

4:31 am on Mar 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The quality issue is the stumbling block to any automatic, on-size-fits-all answer. If the color palette of the image is relatively, restricted then gif or png may be best -- even though the image is a photo.

The algorithms for compression have been improved significantly in recent year. ImageReady (the Photoshop companion application) is now quite amazing. It started out good but now that we're up to version it's truly amazing. But the best results need human intervention.

Sometimes a static Flash file (swf) is the best because of the vector possibilities. But it all depends on the image content and how well any one algorithm can trick the human eye.

Farix

5:43 am on Mar 30, 2005 (gmt 0)

10+ Year Member



As for which image format yields the best quality for the smallest size, there really are no one-size-fits-all solutions. My general rule of thumb is to use JPEG when it is a photorealistic image and PNG for line art, most gradients, simple images and images I want to archive in a lossless format. I only use GIF for the most extreme cases, very small files with a very small color pallet. Otherwise, PNG beats GIF nearly every time.

Now to get the smallest PNG files I can get, I have a utility that runs the original image through a pallet optimizer (pngrewrite), then calls one optimization program (pngout) to run both the original image and the results of the pallet optimizer. And finally a third optimization program (pngcrush) to optimize the original and output of all other optimization programs. With some tweaking, I can even have it convert a GIF image to PNG.

A bit excessive? Maybe. But I happen to like the results I get.

kaled

9:26 am on Mar 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In practice, how good is png support in IE? I just did a quick check and found a substantial list of proplems. Is it safe to ignore them?

[libpng.org...]

Kaled.

Farix

1:05 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



So long as you don't use alpha-channel transparency, you should be perfectly safe with PNG. But even then, there are some things you can do to get alpha-channel transparency to work under IE 5.5 and up.

website

7:05 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



everytime i investigated png files, it seemed they just werent as advanced as the other types of compression. That comprssion software you describbed seems to peak my interst though, are there any tools out there that can do the same for jpeg? I will switch to png if that software can amaze me enough to do so.

can someone post file size figures on how small they can compress a 32 x 32 pixel image in the best quality available, and do so using the three seperate formats? This will prove which compression is actually superior, and maybe also enlighten us on how to do it? :)

Farix

8:34 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



As I said before, this really isn't a cut and dry answer where one format is superior to all others. It really depends on the types of image you are trying to compress.

And a 32x32 image of what, a single color, a gradient, a photorealistic image or line art? And what about the color depth? Do you want to preserve as much information in a lossless format in case you need to edit the image later? Because the types of image and your situation will determine which file format is best to use.

Oh and for those who are interested in my little utility, here it is. First create a main directory to store the utility files (in my case PNG/), then place a copy of the the following utilities: pngrewrite, pngout and pngcrush. Underneath the main directory, create two subdirectories finished/ and original/. Finally create the following two batch files.

crush.bat


@echo off
del /q finished\*.*
for %%x in (originals\*.png) do call processer %%~dpnx
pngcrush -brute -reduce -rem alla -d finished originals\*.png

processor.bat


rename %1.png %~n1-1.png
pngrewrite %1-1.png %1-2.png
pngout %1-2.png %1-3.png
pngout %1-1.png %1-4.png

After that it is just a matter of putting the original files in the original\ subdirectory, run 'crush' from the main directory, then sort through the finished\ subdirectory and pick the version with the best compressed results (usually -3 or -4).

website

2:16 am on Mar 31, 2005 (gmt 0)

10+ Year Member



i see, so it is image dependant... there needs to be a compression format that is a "end all solution" for anything it compresses. Whoever makes that could make a killing.

for your program, how much of a file size decrease do you see on avergage per file?

Farix

2:46 am on Mar 31, 2005 (gmt 0)

10+ Year Member



I don't think anyone will come up with a file format that will maximize compression for all image types without a huge advance in compression technology in general. And even then there still will be a battle between a lossless format that preserves image quality vs. a lossy format that sacrifices image quality for better compression and 8-bit pallets vs. 24-bit pallets. Then there is the issues of transparency, animation, etc. that image formats deal with.

Why are you so insistent for a one-size-fits-all format in the first place?

swoop

3:10 am on Mar 31, 2005 (gmt 0)

10+ Year Member



I can envision a new image format, call it NIF, that would trial-compress an image as GIF, JPG and PNG and (probably with manual intervention, but software could help) select the best one. Then it would indicate the compression-method code as the first bits of the image file.

The browser would read the first bits to decide how to decompress the file.

tedster

3:35 am on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's essentially what Adobe ImageReady can do - compare the three formats for you, both visually and for file size. You can change different settings, including compression % on jpg (progressive and standard), inspecting the results of dithering changes and alpha channel filtering on gif color look up tables - even force certain colors into the palette and allow the algo to choosethe others.

Really, there's no other application like this from what I know. And the more you understand the three formats technically, the more fine tuned your control.

But it won't do spectacular tricks for you on automatic pilot. How can software decide what "looks" best, or exactly where in a particular image the palette needs to use more colors and where it can afford to just use a couple?

[edited by: tedster at 3:38 am (utc) on Mar. 31, 2005]

website

3:37 am on Mar 31, 2005 (gmt 0)

10+ Year Member



that is a really good idea... you would be in buisness if you could actually implament it. Basically i want to build a site as optimized as it could be and by doing this i would need to have all my images load the fastest way possible. i am just curious as the methods and ways this is posible so that when i am building i can ensure that i am fast as i can possibly using the best technology.

not trying to be obssessive, just want a general idea of what is out there... something i might not know

website

3:40 am on Mar 31, 2005 (gmt 0)

10+ Year Member



but for imageready, is the file that comes out (size and quality wise) better than those made in other applications?

tedster

3:55 am on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Image compression is a mighty complex marriage between art and technology. Here are some of the factors that I know about just for a GIF:

1. Choosing the number of colors (of course)
2. Hand edit the color lookup table
3. Use a channel to influence the color assignments for each pixel
4. Vary between perceptual, selective, adaptive and web color palettes
5. Apply web color restrictions by a percentage
6. Control dithering by type (diffusion, custom pattern, random noise) and by percentage
7. Interlaced or regular format
8. Choosing "lossy" compression by a percentage, and by channel influence

Each of these is a technical possibility, but the choices also depend on a trained eyeball. And them there's the kind of thing you can achieve just by preparing an image before you get to the compressed format. The more you know the tricks that these formats use to compress an image, the more you can help them out with some judicious pre-prep.

I can often take a photo-realistic image, even one with a gradient sky for instance, and create a gif that beats a jpg visually and in total file size. Not always - it depends on the color range of the original and other things. But there is no hard and fast rule. Sometimes line art works better as a jpg than a gif, especially if a degree of subtlety is required for the final effect.

We can probably expect better and better technology, but someone still has to tweak the dials and eyeball the results. I honestly expect WYSIWYG HTML editors to put out valid html long before we see a magic image compression application.

The biggest issue I see is images that need sharp text over a glorious photographic image. The best results I've seen come from a background photo in jpg and a foreground gif or png for the text, with transparency.

Thanks for css-p to making this possible. You can get the advantages of both formats.

website

5:58 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



wow, thank you that is very informative. Do you use imageready as your main graphic editing/compression tool? As of right now i am using Fireworks MX, this has a pretty good compression utiliy (probly not much different than most similar apps).

also do you know of any other guides like the one you gave for other formats besides just .gif?

im sorry if i sound greedy, i just want to become very familiar with the techniques so that the graphics are implemented in the best possible way.

rocknbil

3:23 am on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Each of these is a technical possibility, but the choices also depend on a trained eyeball.

This is the true bottom line on compression. No single format excels over another, it's more about what you want to do and how it looks when done. This is why I simply refuse to use auto exports of any kind, including FireWorks, ImageReady, or Flash.

Both jpg and gif create a palette for a given image, and map out the coordinates of each color. In the case of jpg, it interpolates many values to eliminate some of the colors, but it's a mathematical automated process. Like any automated process, it often misses the mark. Generally if you can get the color palette of an image low enough, a .gif will sometimes exceed the quality of a jpg.

Example: ever saved a jpg with large white areas and found speckles in the white areas where there should be none? Sometimes you can just save it as a .gif, force black and whites to stay black and white, and the image comes out superior to a jpg.

I've also come across another odd difference: had a project where I was forced (by customer constraints) to put an image in a table. The composite image had graphic non-image white areas as previously described, so I needed to make one cell hold a small .gif portion of the image, while the larger cell held a continuous tone jpg. Worked fine on every single browser . . .

. . . except Safari for Mac. The .jpg images were completely different in color than the gifs, night and day. Wound up making the whole mess .gifs, and large than it needed to be.

And guess what platform the customer preferred. :-)

tedster

4:36 am on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For a short stretch (around Photoshop 6/Imageready 6), I think the Macromedia algorithms did a better job of compression/quality trade-offs. But Adobe really took off after that.

However, if you want a scalable animation - and sometimes just a scalable still frame - Flash can trump anything a pixel-based image will be able to accomplish.

any other guides

Not really, I've been looking to write up something that puts a chunk of what I've learned all in one place. If I get around to it, I will post it in our Graphics and Multi-media Forum.

For the most part, I think that Adobe's automated alogrithms are the way to go with jpg and gif today. There is a bit of manual image pre-prep than can help just a bit, but the advantage is usually minimal enough that in a production environment, I don't bother. On an art site, or when creating an important "image" page, then I might.

Quick pre-prep trick for improving jpg compression:
Import the source image into L*a*b color space. This space puts the detail into the L channel and lets the a & b channels hold all the color minformation. You can often blur the daylights out of both the a & b channels without losing any information the eye really needs. This color blurring helps jpg squish things further.

I'm talking about Gaussian Blur of 3 and 4 pixels. Try that on an RGB channel and you'll trash the image. If there are sharply contrasting color edges, you can avoid color bleed by selecting those edges and running a Gaussian Blur on the inverted selection.

Then when you go back to RGB space, jpg compression can do a better job.

If image size is not a big issue for a given image, you can sometimes bring out amazing subtly in an image by first going to L*a*b and working the contrast and sharpening filters on the L channel.

website

2:12 am on Apr 5, 2005 (gmt 0)

10+ Year Member



once again tedster... insanely informative post. Do you have alot of experiance trying to compress images? i am really looking forward to that guide :)