JPEG
|
|
Note:
Text, images, file-size-data, or links may be added
or improved --- if/when I revisit this page.
INTRODUCTION to the 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 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.
Below 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. |
File size Filename
(bytes) (with an ID-string and short description)
-------- -----------------------------------------------------------------
85,963 seamonkeyGUI_upperLeft_screenshot_246x115.png
P:
the 'original' captured-and-cropped PNG file.
33,052 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped.jpg
PtoJ100:
the original PNG converted to quality100 JPEG.
17,176 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality94_Stripped.jpg
PtoJ100toJ94:
the quality100 JPEG converted to a quality94 JPEG.
15,847 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality93_Stripped.jpg
PtoJ100toJ93:
the quality100 JPEG converted to a quality93 JPEG.
14,859 seamonkeyGUI_upperLeft_screenshot_246x115_Quality92_
Stripped_Quality92_Stripped.jpg
PtoJ92toJ92:
the quality92 JPEG, below, converted to
a quality92 JPEG, again.
14,859 seamonkeyGUI_upperLeft_screenshot_246x115_Quality92_
Stripped_Quality92_Stripped_Quality92_Stripped.jpg
PtoJ92toJ92toJ92:
the quality92-quality92 JPEG, just above,
converted to a quality92 JPEG, again.
14,857 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality92_Stripped.jpg
PtoJ100toJ92:
This file, along with other 'PtoJ100toJxx' files,
is of particular interest to me --- because I
used to create 'quality 100' JPEG files to avoid
losing color information. This file 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. The quality of the
'PtoJ100toJxx' files files can be examined in a
test-images section below. See comments on
'mosquito noise' that appears in some images.
14,799 seamonkeyGUI_upperLeft_screenshot_246x115_Quality92_
Stripped.jpg
PtoJ92:
the original PNG converted to quality92 JPEG.
14,799 seamonkeyGUI_upperLeft_screenshot_246x115_pngcrushBRUTE_
Quality92_Stripped.jpg
PMAXtoJ92:
the 'maximally-compressed' PNG, below, converted
to quality92 JPEG. Note: It is not very surprising
that the 'original' PNG and the 'maximally-compressed'
PNG were both converted to the same sized quality92 JPEG,
by the 'convert -quality 92' command. (This image and
the one above have the same size -- 14,799 bytes.)
12,752 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality92_Stripped_Quality85_Stripped.jpg
PtoJ100toJ92toJ85:
the quality100-to-quality92 JPEG file converted to
quality85 JPEG.
12,710 seamonkeyGUI_upperLeft_screenshot_246x115_pngcrushBRUTE.png
PMAX:
Here is the 'maximally-compressed' PNG file.
Note that the 'quality100-to-quality92' JPEG file,
above, is not much larger. And the
'quality100-to-quality85' and the
'quality100-to-quality80' 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.
10,941 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality85_Stripped.jpg
PtoJ100toJ85:
'quality100' JPEG converted to 'quality85'.
9,287 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality80_Stripped.jpg
PtoJ100toJ80:
'quality100' JPEG converted to 'quality80'.
If 'mosquito noise' around text is noticeable in
this image, I would go with the 'quality100-to-quality85'
or the 'quality100-to-quality92' image above.
8,861 seamonkeyGUI_upperLeft_screenshot_246x115_Quality100_
Stripped_Quality92_Stripped_Quality80_Stripped.jpg
PtoJ100toJ92toJ80:
the quality100-to-quality92 JPEG file
converted to quality80 JPEG.
7,249 seamonkeyGUI_upperLeft_screenshot_246x115_Quality80_
Stripped.jpg
PtoJ80:
the original PNG converted to quality80 JPEG.
7,188 seamonkeyGUI_upperLeft_screenshot_246x115_PALETTE256.gif
PtoG256:
the original PNG converted to 256-colors-max GIF.
7,165 seamonkeyGUI_upperLeft_screenshot_246x115_Quality80_
Stripped_Quality80_Stripped.jpg
PtoJ80toJ80:
the quality80 JPEG file, above,
converted to quality80 JPEG, again.
7,157 seamonkeyGUI_upperLeft_screenshot_246x115_Quality80_
Stripped_Quality80_Stripped_Quality80_Stripped.jpg
PtoJ80toJ80toJ80:
the quality80-to-quality80 JPEG file, just above,
converted to quality80 JPEG, again.
5,142 seamonkeyGUI_upperLeft_screenshot_246x115_Quality60_
Stripped.jpg
PtoJ60:
the original PNG converted to quality60 JPEG.
5,127 seamonkeyGUI_upperLeft_screenshot_246x115_Quality60_
stripped_Quality60_Stripped.jpg
PtoJ60toJ60:
the quality60 JPEG file, just above,
converted to quality60 JPEG, again.
5,120 seamonkeyGUI_upperLeft_screenshot_246x115_Quality60_
Stripped_Quality60_Stripped_Quality60_Stripped.jpg
PtoJ60toJ60toJ60:
the quality60-to-quality60 JPEG file, just above,
converted to quality60 JPEG, again.
4,023 seamonkeyGUI_upperLeft_screenshot_246x115_Quality40_
Stripped.jpg
PtoJ40:
the original PNG converted to quality40 JPEG.
4,020 seamonkeyGUI_upperLeft_screenshot_246x115_Quality40_
Stripped_Quality40_Stripped.jpg
PtoJ40toJ40:
the quality40 JPEG file, just above,
converted to quality40 JPEG, again.
4,020 seamonkeyGUI_upperLeft_screenshot_246x115_Quality40_
Stripped_Quality40_Stripped_Quality40_Stripped.jpg
PtoJ40toJ40toJ40:
the quality40-to-quality40 JPEG file, just above,
converted to quality40 JPEG, again.
2,788 seamonkeyGUI_upperLeft_screenshot_246x115_Quality20_
Stripped.jpg
PtoJ20:
the original PNG converted to quality20 JPEG.
2,784 seamonkeyGUI_upperLeft_screenshot_246x115_Quality20_
Stripped_Quality20_Stripped_Quality20_Stripped.jpg
PtoJ20toJ20toJ20:
the quality20-to-quality20 JPEG file, just below,
converted to quality20 JPEG, again.
2,781 seamonkeyGUI_upperLeft_screenshot_246x115_Quality20_
Stripped_Quality20_Stripped.jpg
PtoJ20toJ20: the quality20 JPEG file, above,
converted to quality20 JPEG, again.
DISCUSSION OF SIZES of the 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) --- of this particular limited-color image --- 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 : 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 : 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 conversion images)
(Click on these images to see the image in
a separate window and magnified 300-percent.)
ImageID: P
The 'original' cropped PNG file from 'gnome-screenshot' and 'mtpaint'.
File size: 85,963 bytes
(The 'mtpaint' image-editor saves to a rather large PNG file.)
ImageID: PtoJ100
'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'.
ImageID: PtoJ100toJ94
'PtoJ100' JPEG to new JPEG via 'convert -strip -quality 94'.
File size: 17,176 bytes
About 60% of the size of 'PtoJ100'.
ImageID: PtoJ100toJ93
'PtoJ100' JPEG to new JPEG via 'convert -strip -quality 93'.
File size: 15,847 bytes
About 50% of the size of 'PtoJ100'.
ImageID: PtoJ92toJ92
'PtoJ92' JPEG, seen below, to
new JPEG via 'convert -strip -quality 92'.
File size: 14,859 bytes
Slightly larger than the input file, 'PtoJ92'.
ImageID: PtoJ92toJ92toJ92
'PtoJ92toJ92' JPEG, just above, to
new JPEG via 'convert -strip -quality 92'.
File size: 14,859 bytes
Exact same size as input file, 'PtoJ92toJ92'.
ImageID: PtoJ100toJ92
'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.
NOTE:
This file is of particular interest to me,
since I may want to convert some quality-100
JPEG files to quality-92.
This 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.
The quality is good --- no 'mosquito noise'.
Also see 'PtoJ100toJ85' and 'PtoJ100toJ80' below.
ImageID: PtoJ92
'original' PNG to JPEG via 'convert -strip -quality 92'
File size: 14,799 bytes
About 45% of the size of the 'PtoJ100' file.
ImageID: PMAXtoJ92
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.
ImageID: PtoJ100toJ92toJ85
'PtoJ100toJ92' JPEG, above, to new JPEG via 'convert -strip -quality 85'
File size: 12,752 bytes
Some 'mosquito noise'.
ImageID: PMAX
The 'original' PNG to new PNG via 'pngcrush -brute'
File size: 12,710
No 'mosquito noise'.
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.
However, the JPEG compression is 'lossy'.
ImageID: PtoJ100toJ85
'PtoJ100' to new JPEG via 'convert -strip -quality 85'
File size: 10,941 bytes
Some 'mosquito noise'.
ImageID: PtoJ100toJ80
'PtoJ100' to new JPEG via 'convert -strip -quality 80'
File size: 9,287 bytes
Some 'mosquito noise'.
ImageID: PtoJ100toJ92toJ80
'PtoJ100toJ92' to new JPEG via 'convert -strip -quality 80'
File size: 8,861 bytes
Some 'mosquito noise'.
ImageID: PtoJ80
'original' PNG to JPEG via 'convert -strip -quality 80'
File size: 7,249 bytes
Some 'mosquito noise'.
ImageID: PtoG256
'original' PNG to un-dithered GIF via
'convert +dither -colors 256'
File size: 7,188 bytes
No 'mosquito noise'.
ImageID: PtoJ80toJ80
'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'.
Some 'mosquito noise'.
ImageID: PtoJ80toJ80toJ80
'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.
Some 'mosquito noise'.
ImageID: PtoJ60
'original' PNG to JPEG via 'convert -strip -quality 60'
File size: 5,142 bytes
About half the size of 'PtoJ85'.
But strong 'mosquito noise'.
ImageID: PtoJ60toJ60
'PtoJ60', above, to new JPEG via 'convert -strip -quality 60'
File size: 5,127 bytes
Slightly smaller than the input file, 'PtoJ60'.
Strong 'mosquito noise'.
ImageID: PtoJ60toJ60toJ60
'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).
Strong 'mosquito noise'.
ImageID: PtoJ40
'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.
ImageID: PtoJ40toJ40
'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'.
The 'mosquito noise' is quite bad.
ImageID: PtoJ40toJ40toJ40
'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.
The 'mosquito noise' is quite bad.
ImageID: PtoJ20
'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.
ImageID: PtoJ20toJ20toJ20
'PtoJ20toJ20' JPEG, below, to new JPEG via
'convert -strip -quality 20'
File size: 2,784 bytes
Almost the same size as 'PtoJ20'.
The 'mosquito noise' is really unacceptable.
ImageID: PtoJ20toJ20
'PtoJ20' JPEG, above, to new JPEG via
'convert -strip -quality 20'
File size: 2,781 bytes
Almost the same size as 'PtoJ20'.
The 'mosquito noise' is really unacceptable
MORE JPEG-MULTI-COMPRESSION 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 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 this 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.
< Go to Top of Page, above. >
Page history:
Page was created 2015 Mar 04.
|