Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Improve quality JPG
#1
Hello

if i save a jpg image with an initial quality of 86 with quality of 90, will i gain in quality? what happens if i do that?

many many thxxx Smile Shy
Reply
#2
(05-04-2021, 02:55 PM)quand Wrote: Hello

if i save a jpg image with an initial compression of 86 with a compression of 90, will i gain in quality? what happens if i do that?

many many thxxx Smile Shy

As I understand it JPEG compression works by saying that two colours that are very similar can be recorded as the same colour - thereby losing information. The lower the compression number the further apart colours can be and still be considered the same colour - thereby losing more information. Once the information has been lost there is (effectively) no way of getting it back.

Simply opening the image and resaving with a higher compression number should have no effect.

Unless it's an image of no importance then always keep a copy in a format that doesn't involve lossy compression - for instance tiff, xcf. Then edit this version, exporting to jpg when required.
Reply
#3
(05-04-2021, 03:43 PM)programmer_ceds Wrote:
(05-04-2021, 02:55 PM)quand Wrote: Hello

if i save a jpg image with an initial compression of 86 with a compression of 90, will i gain in quality? what happens if i do that?

many many thxxx Smile Shy

As I understand it JPEG compression works by saying that two colours that are very similar can be recorded as the same colour - thereby losing information. The lower the compression number the further apart colours can be and still be considered the same colour - thereby losing more information. Once the information has been lost there is (effectively) no way of getting it back.

Simply opening the image and resaving with a higher compression number should have no effect.

Unless it's an image of no importance then always keep a copy in a format that doesn't involve lossy compression - for instance tiff, xcf. Then edit this version, exporting to jpg when required.


Shy

okay, very well, please excuse my question which is that of the beginner that I am; in any case, I thank you.

Is it possible with Gimp to know at what level of compression a jpeg image taken from the internet has been saved?

thank you 
Reply
#4
(05-04-2021, 03:51 PM)quand Wrote: okay, very well, please excuse my question which is that of the beginner that I am; in any case, I thank you.

Is it possible with Gimp to know at what level of compression a jpeg image taken from the internet has been saved?

thank you 

No problem with asking the question.

I think that determining the compression level used when the image was saved by inspecting the image would be a very imprecise thing to do - the compression level isn't saved in the file for instance. Perhaps some qualitative estimate based on the variation in colours - but not really of much use.
Reply
#5
(05-04-2021, 04:19 PM)programmer_ceds Wrote:
(05-04-2021, 03:51 PM)quand Wrote: okay, very well, please excuse my question which is that of the beginner that I am; in any case, I thank you.

Is it possible with Gimp to know at what level of compression a jpeg image taken from the internet has been saved?

thank you 

No problem with asking the question.

I think that determining the compression level used when the image was saved by inspecting the image would be a very imprecise thing to do - the compression level isn't saved in the file for instance. Perhaps some qualitative estimate based on the variation in colours - but not really of much use.

okay many many thxxx Smile You're great Smile
Reply
#6
There is a jpeg compression value saved with image information.  No direct way to view using Gimp. Utilities like ImageMagick command line and XnView (GUI) will show a value.   In Gimp, do a 'fake' Export As and toggle the Use quality settings from original image Then look at the quality value above that. No need to export just cancel it.

   

You will not get any improvement in image quality by going from 85 to 95
JPEG compression is lossy but the quality <-> compression curve is not linear.  Very little difference in viewable quality 100 down to say 85 with much change in file size. 70 down to 40 quality suffers with little change in file size.

If you do not make any changes to the image, you can re-compress (export) several times with no appreciable loss. However, JPEG is an 'on completion of editing' format. Always save in a lossless format Gimp .xcf or export to tif / png until editing is complete.
Reply
#7
(05-04-2021, 04:19 PM)programmer_ceds Wrote:
(05-04-2021, 03:51 PM)quand Wrote: okay, very well, please excuse my question which is that of the beginner that I am; in any case, I thank you.

Is it possible with Gimp to know at what level of compression a jpeg image taken from the internet has been saved?

thank you 

No problem with asking the question.

I think that determining the compression level used when the image was saved by inspecting the image would be a very imprecise thing to do - the compression level isn't saved in the file for instance. Perhaps some qualitative estimate based on the variation in colours - but not really of much use.

Gimp knows... The first line at the top of the JPG export dialog is the option Use quality settings from the original image!!!

Also, there are two things in JPEG that make the image take less space:

  1. The "Chroma subsampling". The takes advantage that our eyes are not as good on color than on brightness(*). So instead of being stored as three R+G+B images, the image is stored as a Luminosity/brightness channel (more or less the B&W version of the image), and two "chroma" channels. Instead of storing the two chroma images at the same definition as the Luma image, the JPEG file can store them as and image which is scaled to half in one dimension or to half in two dimensions. So in an image with P pixels, instead of storing 3×P values, you store P+.5×P+.5×P=2×P (chroma halved) or P+.25×P+.25×P=1.5×P (chroma quartered). In this case we have divided the amount of data by two (1.5×P instead of 3×P) without even doing compression. The JPEG from my DSLR are at quality 97 but with halved chroma, so the engineers at Canon have likely checked that most people won't notice.  
  2. Then we have the compression of the data in each channel, using the "quality". In some apps you can only specify a "quality" but they link the subsampling to quality ranges. In othe rapps such as Gimp you can specify both. So when we talk about the "same quality", does it include the subsampling? The compression is lossy but the algorithm is "stable". If you decompress and recompress with the same settings, the data settles rather quickly on values that won't change. So, strangely, you may lose more data by changing to a higher quality setting than by reusing the current ones. But this of course assumes that you are using the very same code each time, so if the image doesn't come from Gimp (on Linux, from any app that uses libjpeg) this is not true.
(*) Try this with a picture:
  • make a copy of the layer, and desaturate to luminance
  • make a second copy of the original layer drag it to the top
  • Layer>Scale layer and scale it to 25% (each side divided by 24)
  • Layer>Scale layer and scalte it back to its initial size. You should see something somewhat blurry.
  • Set you blurred layer to LCh color blend mode, thus adding its color to the monochrome version.
  • Compare with original
   
Reply
#8
(05-04-2021, 05:11 PM)rich2005 Wrote: There is a jpeg compression value saved with image information.  No direct way to view using Gimp. Utilities like ImageMagick command line and XnView (GUI) will show a value.   In Gimp, do a 'fake' Export As and toggle the Use quality settings from original image Then look at the quality value above that. No need to export just cancel it.



You will not get any improvement in image quality by going from 85 to 95
JPEG compression is lossy but the quality <-> compression curve is not linear.  Very little difference in viewable quality 100 down to say 85 with much change in file size. 70 down to 40 quality suffers with little change in file size.

If you do not make any changes to the image, you can re-compress (export) several times with no appreciable loss. However, JPEG is an 'on completion of editing' format. Always save in a lossless format Gimp .xcf or export to tif / png until editing is complete.

oh okay many many thxxx for everything, very interesting, really Smile

(05-04-2021, 05:35 PM)Ofnuts Wrote:
(05-04-2021, 04:19 PM)programmer_ceds Wrote:
(05-04-2021, 03:51 PM)quand Wrote: okay, very well, please excuse my question which is that of the beginner that I am; in any case, I thank you.

Is it possible with Gimp to know at what level of compression a jpeg image taken from the internet has been saved?

thank you 

No problem with asking the question.

I think that determining the compression level used when the image was saved by inspecting the image would be a very imprecise thing to do - the compression level isn't saved in the file for instance. Perhaps some qualitative estimate based on the variation in colours - but not really of much use.

Gimp knows... The first line at the top of the JPG export dialog is the option Use quality settings from the original image!!!

Also, there are two things in JPEG that make the image take less space:

  1. The "Chroma subsampling". The takes advantage that our eyes are not as good on color than on brightness(*). So instead of being stored as three R+G+B images, the image is stored as a Luminosity/brightness channel (more or less the B&W version of the image), and two "chroma" channels. Instead of storing the two chroma images at the same definition as the Luma image, the JPEG file can store them as and image which is scaled to half in one dimension or to half in two dimensions. So in an image with P pixels, instead of storing 3×P values, you store P+.5×P+.5×P=2×P (chroma halved) or P+.25×P+.25×P=1.5×P (chroma quartered). In this case we have divided the amount of data by two (1.5×P instead of 3×P) without even doing compression. The JPEG from my DSLR are at quality 97 but with halved chroma, so the engineers at Canon have likely checked that most people won't notice.  
  2. Then we have the compression of the data in each channel, using the "quality". In some apps you can only specify a "quality" but they link the subsampling to quality ranges. In othe rapps such as Gimp you can specify both. So when we talk about the "same quality", does it include the subsampling? The compression is lossy but the algorithm is "stable". If you decompress and recompress with the same settings, the data settles rather quickly on values that won't change. So, strangely, you may lose more data by changing to a higher quality setting than by reusing the current ones. But this of course assumes that you are using the very same code each time, so if the image doesn't come from Gimp (on Linux, from any app that uses libjpeg) this is not true.
(*) Try this with a picture:
  • make a copy of the layer, and desaturate to luminance
  • make a second copy of the original layer drag it to the top
  • Layer>Scale layer and scale it to 25% (each side divided by 24)
  • Layer>Scale layer and scalte it back to its initial size. You should see something somewhat blurry.
  • Set you blurred layer to LCh color blend mode, thus adding its color to the monochrome version.
  • Compare with original

many many thxxx for this very very interesting presentation, really
Smile
Reply
#9
(05-04-2021, 05:35 PM)Ofnuts Wrote: Gimp knows... The first line at the top of the JPG export dialog is the option Use quality settings from the original image!!!

But is the compression level saved in the JPEG?

The GIMP function jpeg_detect_quality() contains the comments:

Code:
* Returns the exact or estimated quality value that was used to save
* the JPEG image by analyzing the quantization table divisors.
*
* If an exact match for the IJG quantization tables is found, then a
* quality setting in the range 1..100 is returned.  If the quality
* can only be estimated, then a negative number in the range -1..-100
* is returned; its absolute value represents the maximum IJG quality
* setting to use.  If the quality cannot be reliably determined, then
* 0 is returned.

Perhaps it is more correct to say "Gimp thinks it knows..." Smile
Reply
#10
(05-04-2021, 10:47 PM)programmer_ceds Wrote: Perhaps it is more correct to say "Gimp thinks it knows..." Smile

Gimp happens to know most of the time, and agrees with IM's identify on the quality index of a given file.
Reply


Forum Jump: