What Determines The File Size Of A Photo


If you are designing a Web site, sending digital photographs as e-mail attachments or trying to pack as many images on a floppy disk as possible, the size of each image is important. What you want to do is shrink the file size to as few bytes as possible without hurting the image quality. Most Web sites that publish photographs use the JPEG (pronounced "jay-peg") format for their images. It lets you adjust the amount of compression. Most image-handling programs let you tweak the JPEG compression ratio in one way or another. For example, Paint Shop Pro lets you adjust the compression ratio on a scale from 1 to 99, with 1 offering the best image quality and lowest compression ratio and 99 offering the lowest quality and highest compression. The following images give you some sense of the effect that different compression ratios can have on image quality. In all cases, I started with the same 400x336-pixel image. The original JPEG image at 1-percent compression (maximum quality) takes up 152 kilobytes of disk space, so it is not even included.


Besides, there is no difference between 1-percent compression and 20-percent compression in terms of image quality, even though the size of the file goes down by a factor of four! When I look at this particular image, I can begin to see minor degradation at 60-percent compression (most visible on the border of the blue shirt). Eighty-percent and 90-percent compression is progressively worse, and 95-percent compression is badly pixelated. Forty- or 50-percent compression is probably a good value for this image, with an image size of 20 to 25 kilobytes. Another way to lower the size of the file is to reduce the image size. This smaller image size reduces the file size by a factor of two! If your scanner is creating 100-kilobyte files, then your scanner is probably producing images in an uncompressed or slightly compressed JPEG format. Using a program like Paint Shop Pro, you can open the image and re-save it at a different compression ratio to shrink the file size significantly. Why are there so many different image formats on the web? My scanner has a resolution of 9,600x1,200 dpi -- what do those numbers mean? Some photo files are bigger than others because they are a higher quality or resolution. What determines the file size of a photo? The file size of a photo is determined by the number of pixels in the photo.


Please beware that as of 18th November the W3C is no longer actively working on the Web SQL Database specification. The Web SQL database API isn’t actually part of the HTML5 specification, but it is part of the suite of specifications that allows us developers to build fully fledged web applications, so it’s about time we dig in and check it out. What’s in the box? If you haven’t guessed from the overly verbose specification title, Web SQL Databases is a spec that brings SQL to the client side. If you have a back-end developer’s background, then you’ll probably be familiar with SQL and happy as a pig in muck. If not, you might want to learn some SQL before you start hacking around, Google’s your friend here. The specification is based around SQLite (3.1.19), but having come from MySQL myself, it’s all pretty much the same (sorry for the sweeping statement!). For an example of Web SQL Databases working, have a look at the Twitter HTML5 chatter demo I put together.


Support is a little patchy at the moment. Only Webkit (Safari, SafariMobile and Chrome) and Opera 10.50 (ATOW alpha on Mac) support web databases. Fellow Doctor Bruce Lawson has told me that Firefox are holding off as they feel there’s a better implementation than SQLite (though I hope it’s similar, whatever they pick). Either way, I’d definitely recommend checking out the SQLite documentation for the functions that are available. Because of this patchy support and the simple fact that Webkit had implemented the database spec some time ago, the spec on the W3C is now slightly ahead of the implementations in Safari, while Webkit is still catching up. On the other hand, since Opera has only just added support, it’s closer to the spec (I’ll mention the differences as we go along). Nonetheless, it’s fun to play with, so let’s get playing! If you try to open a database that doesn’t exist, the API will create it on the fly for you.