Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a quality, file-size, or other benefit to JPEG sizes being multiples of 8px or 16px?

The JPEG compression encoding process splits a given image into blocks of 8x8 pixels, working with these blocks in future lossy and lossless compressions. [source]

It is also mentioned that if the image is a multiple 1MCU block (defined as a Minimum Coded Unit, 'usually 16 pixels in both directions') that lossless alterations to a JPEG can be performed. [source]

I am working with product images and would like to know both if, and how much benefit can be derived from using multiples of 16 in my final image size (say, using an image with size 480px by 360px) vs. a non-multiple of 16 (such as 484x362). In this example I am not interested in further alterations, editing, or recompression of the final image.

To try to get closer to a specific answer where I know there must be largely generalities: Given a 480x360 image that is 64k and saved at maximum quality in Photoshop [example]:

  • Can I expect any quality loss from an image that is 484x362
  • What amount of file size addition can I expect (for this example, the additional space would be white pixels)
  • Are there any other disadvantages to growing larger than the 8px grid?

I know it's arbitrary to use that specific example, but it would still be helpful (for me and potentially any others pondering an image size) to understand what level of compromise I'd be dealing with in breaking the non-8px grid.

The key issue here is a debate I've had is whether 8-pixel divisible images are higher quality than images that are not divisible by 8-pixels.

like image 844
Dave Rutledge Avatar asked Sep 16 '08 17:09

Dave Rutledge


People also ask

What is a good quality JPEG size?

As a general benchmark: 90% JPEG quality gives a very high-quality image while gaining a significant reduction on the original 100% file size. 80% JPEG quality gives a greater file size reduction with almost no loss in quality.

Does higher file size mean better quality?

Many people think that lowering the resolution of an image also lowers the file size of the image, allowing it to download faster over the web. But while it's true that smaller files sizes download faster, the resolution of your image has nothing to do with its file size.

How does file size affect image quality?

Size your images for their useAll that extra file size does nothing to help display your image and only slows the loading time for the viewer. Likewise, if you use a small image and make it larger in a report, it will distort and become pixelated or fuzzy when you print it.

How many MB should a JPEG be?

Typically images will be supplied as JPEGs, and an A4 (210mm x 297mm or 8¼” x 11¾”) image at 72 ppi will create a JPEG of approximately 500kb or half a megabyte. Remember though – to use that image in print we need the image to be 300 ppi, and at that resolution the JPEG will be around 3.5 Megabytes.


1 Answers

8 pixels is the cutoff. The reason is because JPEG images are simply an array of 8x8 DCT blocks; if the image resolution isn't mod8 in both directions, the encoder has to pad the sides up to the next mod8 resolution. This in practice is not very expensive bit-wise; what's much worse are the cases when an image has sharp black lines (such as a letterboxed image) that don't lie on block boundaries. This is especially problematic in video encoding. The reason for this being a problem is that the frequency transform of a sharp line is a Gaussian distribution of coefficients--resulting in an enormous number of bits to code.

For those curious, the most common method of padding edges in intra compression (such as JPEG images) is to mirror the lines of pixels before the edge. For example, if you need to pad three lines and line X is the edge, line X+1 is equal to line X, line X+2 is equal to line X-1, and line X+3 is equal to line X-2. This quite effectively minimizes the cost in transform coefficients of the extra lines.

In inter coding, however, the padding algorithms generally simply duplicate the last line, because the mirror method does not work well for inter compression, such as in video compression.

like image 103
Dark Shikari Avatar answered Sep 20 '22 21:09

Dark Shikari