Text, images, file-size-data, or links may be added
or improved --- if/when I revisit this page.
INTRODUCTION to the JPEG MULTI-COMPRESSION EXPERIMENTS :
This is a page of experiments in 'multi-compression' of a JPEG image --- concerned with the quality of the 'multiply-compressed' images --- but also concerned with the file-size results.
Images are shown below, and text under each image indicates how the image file was created.
Before the images, a summary of file sizes is listed (at the bottom of this introduction) --- along with some discussion of the quality and sizes of the image files.
The summary of file sizes is followed by the images, along with comments about each image, underneath each image. (You can click on an image to see the image, magnified, in a separate window.)
This page is a link on the 'parent' web page JPEG vs. PNG vs. GIF - image-quality vs. file-size. The 'Introduction' on that page describes some of the considerations in compressing JPEG/PNG/GIF files while preserving the quality of the original image (in terms of what the eye can see, without magnifying the image).
See 'The bottom line' section of that page. It contains a summary of JPEG/PNG/GIF compression-versus-quality guidelines that were deduced from the image compression experiments in these web pages.
THIS PAGE is meant to explore JPEG files in particular --- specifically, the effect of compressing a JPEG file multiple times --- using the '-quality' option of the ImageMagick 'convert' command.
So note that by saying we compress an image file to a JPEG file, we mean that we are using the 'convert -strip -quality' command to do the compression. (We use '-strip' to assure that unneeded text information within the image file is removed.)
The motivation for these experiments :
In the years 2010 to 2014, I was making lots of web pages that included screenshots and image captures that I had done using the 'gnome-screenshot' command on PC's using a Linux operating system with a Gnome 2.28 desktop environment (Ubuntu 9.10).
The 'gnome-screenshot' command produces a PNG image file of a 'screen capture'. I would typically use the 'mtpaint' image editor program to crop the captured image --- and typically I would, in the end, put the cropped image in a 'quality 100' JPEG file.
I used 'quality 100' (minimal JPEG compression) because I was concerned about losing image quality if I used a lower quality level --- such as 90 or 70. I was concerned because I had read many warnings about JPEG using a 'lossy-compression' algorithm in creating a JPEG file from any other image file format.
I used the 'quality 100' JPEG image files in web pages of mine. Then, in the fall of 2014, it came to my attention that if I would use 'quality 92' for the JPEG files, the images would suffer essentially NO quality loss --- for example, no apparent introduction of 'mosquito noise' around text characters in the image of a GUI.
At the same time, the file sizes of the 'quality 92' JPEG image file would typically be around half the size of the corresponding 'quality 100' JPEG image file.
My typical work flow in creating a JPEG from a screen capture :
The steps in making a 'screen capture' image for one of my web pages were as follows. I will take the example of wanting to display an image of the upper-left portion of the Seamonkey web browser window.
Then, in the winter of 2014-2015, I find out that, by using a lower 'quality' level, I can get much smaller JPEG image files with no NOTICEABLE loss of quality, in many cases --- in particular, in the case of GUI images.
As I discussed on the web page JPEG vs. PNG vs. GIF - image-quality vs. file-size --- I can often, from an 'original' image capture file, get much smaller (high-quality) image files if I use GIF files --- or, at least, JPEG files with a 'quality' option in the 90's or 80's.
There are a couple of reasons why I may want to 'go back' and replace the 'quality 100' JPEG images on some web pages with 'quality 93' say --- or even 'quality 80' --- JPEG image files. The reasons:
So the 'multi-compression JPEG experiments below are meant to see if I can compress a 'quality 100' JPEG image file to a 'quality 92' or 'quality 80' JPEG image file, for example --- with no apparent loss in quality of the image --- using the ImageMagick 'convert' command.
The images on this page :
The images on this page were made from an 'original' image in a PNG file. That image was cropped from the upper-left portion of a screen capture of the Seamonkey web browser GUI.
The images on this page were made as follows.
Here is a list of the sizes (in bytes) and names of the following image files --- sorted by size, largest files first. The filenames indicate the kind of conversion/compression that was done.
I also created a GIF and a PNG file from the 'original' PNG captured-and-cropped image file. I used the ImageMagick 'convert' command with the '-colors 256' option to create a 256-colors (max) GIF file. And I used the 'pngcrush' program with the '-brute' option to create a 'maximally-compressed' PNG file.
Note that the 'maximally-compressed' PNG file offers the advantage of not losing/changing color information for any of the pixels --- which can occur in converting the 'original' PNG file to a GIF or JPEG file.
File size results from various compression tests are listed below --- in file size order --- largest to smallest.
The descriptive file names are quite long and have been 'folded' onto a second line.
'P' denotes the original screenshot PNG file.
DISCUSSION OF SIZES of the 'multi-compressed' JPEG files :
Note that we achieved the maximum loss-less compression of the original PNG file to another PNG file with the '_pngcrushBRUTE.png' file --- created with the 'pngcrush' command with the '-brute' option. That '_pngcrushBRUTE.png' file was about 7 times smaller than the 'original' PNG file.
However, we can get still smaller files, than that PNG file, by allowing some 'lossiness' --- by using the 'lossy' compression inherent in creating JPEG files --- or by going to GIF files (with a max of 256 colors).
The size of the 'brute-crushed' PNG file corresponded to the size of JPEG files of 'quality' about 92 to 80. Using the image-IDs of the table above:
The JPEG files with quality in the 92 to 80 range do NOT show appreciable 'mosquito noise' --- or, at least, the mosquito noise is tolerable down to about quality-85.
For this particular image, if I were posting the image on a web page or including the image in an email --- and IF file size was my main concern --- I would be tempted to use a JPEG file of 'quality' 85 (or even 80) rather than use the loss-less, maximally-crushed PNG file. The JPEG's would be about 20 to 40 percent smaller than the loss-less, maximally crushed PNG file.
But we can get even smaller files (of good quality) by using the GIF format. This is demonstrated with multiple image examples on the JPEG vs. PNG vs. GIF - image-quality vs. file-size page.
On JPEG 'mosquito noise' :
Note that when small text fonts are in an image, the 'lossy' compression of JPEG typically introduces 'mosquito noise' around the small text characters --- especially when we use a 'quality' value lower than the range of 100 to 92.
In this GUI image, there are many 'fine', small text characters --- so we DO have to be concerned about introducing 'mosquito noise' when converting the 'original' PNG file to a JPEG file of 'quality' less than 92.
Significant 'mosquito noise' was generated in the JPEG files of 'quality' 80, 60, 40, and 20 --- which were created from the 'original' PNG file. The mosquito noise is definitely visible in the quality 40 and 20 images, without magnifying the image.
The 256-color GIF file, also created from the 'original' PNG file, has no such 'mosquito noise' and is comparable in size to the JPEG file of 'quality' 80.
On choosing a file-type : (starting from scratch)
For this particular image, IF file size was my main concern (for example, if I were posting the image on a web page along with a lot of other images), as I demonstrated on the JPEG vs. PNG vs. GIF - image-quality vs. file-size page, I would be tempted to use a 16-color (or 32-color) GIF file rather than use the loss-less, maximally-crushed PNG file.
For this particular image, the 256-color GIF file was about 60 percent of the size of the 'brute-crushed' PNG file --- and the 16-color GIF file is about 30 percent of the size of the loss-less, maximally crushed PNG file.
For this particular image, if I were posting the image on a web page, I would be tempted to use the (un-dithered) 16-color GIF file rather than a JPEG or a loss-less, maximally-crushed PNG file --- even though there are undoubtedly some 'lost' colors in the GIF file. I would choose a 16- or 32-color GIF file because there is no apparent loss of image quality for this GUI image, in spite of there being a limit of 16 or 32 colors available in the GIF file.
On choosing a JPEG file-quality : (starting from a quality-100 JPEG)
Having said that about preferring to use a GIF file for this image, I still need to address the situation that I was initially concerned about in performing these experiments --- namely:
I would like to know what 'convert -quality' value I could use to convert an already created 'quality-100' JPEG file to a smaller JPEG file ... with no noticeable loss in image quality.
The bottom line :
From the images below, it looks like the 'PtoJ100toJ92' and 'PtoJ100toJ85' and 'PtoJ100toJ80' images are all pretty good quality --- 'to the human eye'.
When I look at the 300-percent-magnified image of 'PtoJ100toJ80', I can see the 'mosquito noise' is quite apparent. But as long as I do not magnify the image, it looks like the 'PtoJ100toJ80' image would be quite acceptable for use in a web page --- and the size is 9,287 bytes versus 33,052 bytes for 'PtoJ100' --- and 12,710 bytes for 'PMAX'.
If I wanted to be more conservative, I could use 'PtoJ100toJ85' at 10,941 bytes or 'PtoJ100toJ92' at 14,847 bytes --- still a big improvement in file-size over 33,052 bytes for 'PtoJ100'.
Further below are the images. Judge for yourself.
(including a few PNG and GIF compression images)
(Click on these images to see the image in
a separate window and magnified 300-percent.)
The 'original' cropped PNG file from 'gnome-screenshot' and 'mtpaint'.
File size: 85,963 bytes
('mtpaint' saves to a rather large PNG file.)
'original' PNG to JPEG via 'convert -strip -quality 100'
File size: 33,052 bytes
(NOTE: There is NO apparent 'mosquito noise' around the text items in this JPEG.
This image is quite usable, BUT it is more than twice the size of the
quality-92 JPEG file, 'PtoJ92' below, which also shows no 'mosquito noise'.)
'PtoJ100' JPEG to new JPEG via 'convert -strip -quality 94'.
File size: 17,176 bytes
About 60% of the size of 'PtoJ100'.
'PtoJ100' JPEG to new JPEG via 'convert -strip -quality 93'.
File size: 15,847 bytes
About 50% of the size of 'PtoJ100'.
'PtoJ92' JPEG, below, to new JPEG via 'convert -strip -quality 92'.
File size: 14,859 bytes
Slightly larger than the input file, 'PtoJ92'.
'PtoJ92toJ92' JPEG, just above, to new JPEG via 'convert -strip -quality 92'.
File size: 14,859 bytes
Exact same size as input file, 'PtoJ92toJ92'.
'PtoJ100' JPEG, above, to new JPEG via 'convert -strip -quality 92'.
File size: 14,857 bytes
About 45% of the size of the 'PtoJ100' file.
(This file is of particular interest to me. It is the 'quality 100' JPEG file above after
being run through 'convert -quality 92' to create a smaller file than the 'quality 100'
JPEG file. Also see 'PtoJ100toJ85' and 'PtoJ100toJ80' below.)
'original' PNG to JPEG via 'convert -strip -quality 92'
File size: 14,799 bytes
About 45% of the size of the 'PtoJ100' file.
The 'maximally-compressed' PNG, below, converted to JPEG via 'convert -strip -quality 92'
File size: 14,799 bytes
Note: It is not very surprising that the 'original' PNG and the 'maximally-compressed' PNG
were converted to the same sized quality92 JPEG, by the 'convert -quality 92' command.
'PtoJ100toJ92' JPEG, above, to new JPEG via 'convert -strip -quality 85'
File size: 12,752 bytes
The 'original' PNG to new PNG via 'pngcrush -brute'
File size: 12,710
Here is the 'maximally-compressed' PNG file. Note that the 'PtoJ100toJ92'
JPEG file, above, is not much larger. And the 'PtoJ100toJ85' and the
'PtoJ100toJ80' JPEG files, just below, are smaller than the
'maximally-compressed' PNG file. Hence, I can 'convert' quality-100 JPEG files to
JPEG files in the quality 92-to-80 range and have files that are quite competitive
in size to a 'maximally-compressed' PNG file.
'PtoJ100' to new JPEG via 'convert -strip -quality 85'
File size: 10,941 bytes
'PtoJ100' to new JPEG via 'convert -strip -quality 80'
File size: 9,287 bytes
'PtoJ100toJ92' to new JPEG via 'convert -strip -quality 80'
File size: 8,861 bytes
'original' PNG to JPEG via 'convert -strip -quality 80'
File size: 7,249 bytes
'original' PNG to un-dithered GIF via 'convert +dither -colors 256'
File size: 7,188 bytes
'PtoJ80', above, to new JPEG via 'convert -strip -quality 80'
File size: 7,165 bytes
Just a few percent smaller than the input file, 'PtoJ80'.
'PtoJ80toJ80', above, to new JPEG via 'convert -strip -quality 80'
File size: 7,157 bytes
Almost same size as the input file, 'PtoJ80toJ80'
--- and the quality seems to be unchanged.
'original' PNG to JPEG via 'convert -strip -quality 60'
File size: 5,142 bytes
About half the size of 'PtoJ85'.
'PtoJ60', above, to new JPEG via 'convert -strip -quality 60'
File size: 5,127 bytes
Slightly smaller than the input file, 'PtoJ60'.
'PtoJ60toJ60', above, to new JPEG via 'convert -strip -quality 60'
File size: 5,120 bytes
Slightly smaller than the input file, 'PtoJ60toJ60'.
The quality seems to be essentially the same (unchanged).
'original' PNG to JPEG via 'convert -strip -quality 40'
File size: 4,023 bytes
About 20% smaller than 'PtoJ60' --- and less than one-third the size of 'PtoJ92'.
But the 'mosquito noise' is quite bad.
'PtoJ40' JPEG, above, to new JPEG via 'convert -strip -quality 40'
File size: 4,020 bytes
Almost the same size as the input file, 'PtoJ40'.
'PtoJ40toJ40' JPEG, above, to new JPEG via 'convert -strip -quality 40'
File size: 4,020 bytes
Same size as the input file, 'PtoJ40toJ40'.
Quality seems to be essentially the same.
'original' PNG to JPEG via 'convert -strip -quality 20'
File size: 2,788 bytes
About one-fifth the size of 'PtoJ92'.
But the 'mosquito noise' is really unacceptable.
'PtoJ20toJ20' JPEG, below, to new JPEG via 'convert -strip -quality 20'
File size: 2,784 bytes
Almost the same size as 'PtoJ20'.
'PtoJ20' JPEG, above, to new JPEG via 'convert -strip -quality 20'
File size: 2,781 bytes
Almost the same size as 'PtoJ20'.
MORE JPEG-MULTI-COMPRESSION IMAGE EXPERIMENTS :
Some more JPEG-compression experiments may eventually be added to this page --- if questions arise that are not answered by the image experiments above.
'External' WEB LINKS to other JPEG-MULTI-COMPRESSION info :
For more information on image file quality and compression issues, when compressing JPEG files 'multiple times', you can try the following web searches on the indicated keywords.
You may wish to change or add keywords to these queries in order to hone in on answers to your particular questions.
Bottom of page of
To return to a previously visited web page, click on the
Back button of your web browser a sufficient number of times.
OR, use the History-list option of your web browser.
Page was created 2015 Mar 04.