How Image Optimization works?

  • imhungry
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13

Post 3+ Months Ago

What exactly happens to an image when you optimize it for the web?

I am wondering because I would like to make my own custom Image Optimizer.

Any and All help appreciated.

Thnx
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2193
  • Loc: Canada

Post 3+ Months Ago

The number of colours are reduced; frequency of colours and gradients are merged. No clue how the programming end of it works though,
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Think of a 256 color GIF palette.

If you have RGB(255, 255, 255) then in the next pixel you have RGB(255, 255, 254) it's going to save an entry in the palette to snap the latter to 255,255,255.

Basic optimization is looking at the file format you want to save the image to & how many colors it will allow, determining which colors are most popular in the image, building a base palette from that, & snapping colors to this base palette.

Say you have a 2 X 2 pixel image with 2 colors,
FFFFFF = [a0, b1];FFFFFE = [b0, a1]
If you snap the second color your list shrinks,
FFFFFF = [a0, a1, b0, b1];
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2193
  • Loc: Canada

Post 3+ Months Ago

Ah I always thought they worked like that, never really looked into it (which is weird, considering I research all the stupid little things).
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

That's a basic raw bitmap view of it.

When you get into formats like PNG, PSD that save layer & vector information it's a whole new ballgame.

Moved to Digital Art/Photography being it's an image specific question.
  • gaparker
  • Proficient
  • Proficient
  • User avatar
  • Posts: 412
  • Loc: England, uk

Post 3+ Months Ago

im getting some new animation software that i need to get to grips with, flash, its meant to be really good
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

For lossy formats, like jpeg, the optimization is a bit different. It still uses color similarity to do the optimization, and setting the compreassion/quality level determines the threshold.

For example, if you have large areas of "black" in an image, instead of storing data for every pixel in that area, optimization will break it down into a few "Large pixels". If the optimization has determined that a 25x25 block of pixels are similar enough in color to be considered the same, it will store the color, the size and the location of the block, instead of saving the color information for all 625 pixels.

Obviously, the process is much more complex than that, but that's the easiest way I could think of to explain it.

For reference, here are some size comparisons for a few black field images.

jpeg, 0 quality, 1 x 1 : 8KB
jpeg, 12 quality, 1 x 1 : 9KB
jpeg, 0 quality, 640 x 480 : 12KB
jpeg, 12 quality, 640 x 480 : 29KB
bmp, 1 x 1 : 1KB
bmp, 640 x 480 : 901KB

This was done using photoshop 7.01 with the standard "save as..." jpg compression. Note that jpeg format uses this blocking technique for blocks of colors that are exactly the same even at maximum quality, which is why jpeg images are almost always signifigantly smaller than a bitmap of the same image.
I believe jpeg format also employs some form of pattern matching as well. I tested with a 640x480 image of a checkerboard of alternating black and white pixels, and a max quality jpeg was still signifigantly smaller than the bmp version. if it was only using color matching, then I would think that the largest color block it would be able to identify would be a 1x1 pixel, in which case it would have to store a block for each pixel.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 15 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.