Ldina Posted April 28 Share Posted April 28 This is probably covered somewhere on the forum, but I couldn't find it. A recent forum discussion piqued my curiosity about AP's JPG compression algorithm regarding quality loss, file sizes, etc. So, I took an original image (from an old Canon 40D, 2538 x 3866 pixels) and exported to 8-bit RGB TIFF and 15 separate JPGs of varying quality levels (quality 0 to 100). I have generally used Quality 85% up to now, since it usually retains very acceptable quality with a significant reduction in file size. All the exported files are in the attached ZIP file. I picked an image with some fine details and some smoother areas, as JPG compression works differently in high and low frequency portions of the image. I found that anything below a quality of about 20–30% generally resulted in severe posterization and artifacts. JPG quality of 100% results in huge file sizes and is probably not required, except perhaps for special cases. Even lowering the JPG quality from 100% to 95% or 98% results in a significantly smaller file size. Interestingly, large portions of similar, low frequency color (e.g., skies, gradient backgrounds, smooth walls, etc) probably require higher quality levels to avoid visible posterization and artifacts. Higher frequency images can often get away with more compression (i.e., lower quality and smaller file sizes) without it being as noticeable. Below are the file sizes for the various JPG compression qualities (all files were 2538 x 3866 pixels in size). Different files will compress differently depending on saturation, brightness range, amount of detail, etc. JPG 0% 82KB JPG 5% 104KB JPG 10% 157KB JPG 20% 262KB (ones in red were generally pretty bad and resulted in extremely noticeable artifacts) JPG 30% 379KB JPG 40% 497KB JPG 50% 622KB (Not too bad, at least in this test image, but a little soft) JPG 60% 891KB JPG 70% 1.1MB JPG 80% 1.5MB (Acceptable quality in this test image) JPG 85% 1.9MB (A good compromise for my general needs, unless maximum file size reduction is critical) JPG 90% 2.5MB JPG 95% 3.8MB JPG 98% 5.9MB JPG 100% 9.8MB TIFF 8-BIT 15.5MB (no compression) If smaller file sizes are critical, I'd be inclined to reduce JPG Quality level to 50% or even lower, depending on the image, especially on images that are mostly higher frequency. Where gradients and smooth, similarly colored areas are prominent, you may wish 50% or higher. On size doesn't fit all, so some experimentation is usually in order. JPG Quality-Filesize Comparisons.zip Quote 2017 15" MacBook Pro, 16 GB RAM, Ventura v13.7, Affinity Photo/Designer/Publisher v1 & v2, Adobe CS6 Extended, LightRoom v6, Blender, InkScape, Dell 30" Monitor, Canon PRO-100 Printer, i1 Spectrophotometer, i1Publish Link to comment Share on other sites More sharing options...
NotMyFault Posted April 28 Share Posted April 28 For me it looks more like a tutorial than a question. David in Яuislip 1 Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected. Link to comment Share on other sites More sharing options...
Ldina Posted April 28 Author Share Posted April 28 Good point!! 😀 Quote 2017 15" MacBook Pro, 16 GB RAM, Ventura v13.7, Affinity Photo/Designer/Publisher v1 & v2, Adobe CS6 Extended, LightRoom v6, Blender, InkScape, Dell 30" Monitor, Canon PRO-100 Printer, i1 Spectrophotometer, i1Publish Link to comment Share on other sites More sharing options...
Old Bruce Posted April 28 Share Posted April 28 20 minutes ago, Ldina said: If smaller file sizes are critical, I'd be inclined to reduce JPG Quality level to 50% or even lower, depending on the image, ... In my experience I found that a 0.1 - 0.2 pixel blur before exporting would result in smaller file sizes with much higher quality settings and with the same quality settings the file that had the tiny blur applied had far fewer compression artifacts as well as a smaller size. Your comment about one size not fitting all situations is so true, and so frustrating. With the export persona I have found myself spitting out a bunch of different JPEG quality images and then choosing the "best". Rarely is the same setting giving me the smallest/best file for a dozen different images. Ldina and David in Яuislip 2 Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.5.5 | Affinity Photo 2.5.5 | Affinity Publisher 2.5.5 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that. Link to comment Share on other sites More sharing options...
David in Яuislip Posted April 28 Share Posted April 28 27 minutes ago, Old Bruce said: With the export persona I have found myself spitting out a bunch of different JPEG quality images and then choosing the "best" Well that's the traditional way squinting at the display but a real modern nerd would write a powershell script using imagemagick to compare an uncompressed image with decreasing quality settings until the RMSE error is greater than a given amount, say 0.01 This should get you started magick input.png reference.png -metric RMSE -compare -format "%[fx:%[distortion]>0.1]" info: NotMyFault 1 Quote Microsoft Windows 11 Home, Intel i7-1360P 2.20 GHz, 32 GB RAM, 1TB SSD, Intel Iris Xe Affinity Photo - 24/05/20, Affinity Publisher - 06/12/20, KTM Superduke - 27/09/10 Link to comment Share on other sites More sharing options...
lacerto Posted April 29 Share Posted April 29 Obsolete. thomaso and Westerwälder 1 1 Quote Link to comment Share on other sites More sharing options...
thomaso Posted April 29 Share Posted April 29 2 hours ago, lacerto said: raised the default to 98. Wasn't this default changed in an early V2 version from 98 to 95% and mentioned in this forum? Unfortunately it seems the forum search does not work with '%' and ignores a two-digit number. - 2 hours ago, lacerto said: InDesign has had "Automatic (JPEG)" combined with "Maximum" for ages, (…) and it analyzes each image for most suitable and effective packing. That might be the reason that I can't find any info about the specific compression percentage used by ID for PDF export with "Maximum". Quote macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1 Link to comment Share on other sites More sharing options...
walt.farrell Posted April 29 Share Posted April 29 4 hours ago, thomaso said: Unfortunately it seems the forum search does not work with '%' and ignores a two-digit number. Note that it's not Compression, but Quality. Perhaps using that term would help in searching? Or, of course, there's using Google or other web search engine with the added search term site:forum.affinity.serif.com, rather than the forum search. Quote -- Walt Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases PC: Desktop: Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 Laptop: Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU. Laptop 2: Windows 11 Pro 24H2, 16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU iPad: iPad Pro M1, 12.9": iPadOS 18.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1 Link to comment Share on other sites More sharing options...
NotMyFault Posted April 29 Share Posted April 29 Good read https://patrakov.blogspot.com/2008/12/jpeg-quality-is-meaningless-number.html https://stackoverflow.com/questions/2024947/is-it-possible-to-tell-the-quality-level-of-a-jpeg Quote Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected. Link to comment Share on other sites More sharing options...
Ldina Posted April 29 Author Share Posted April 29 @NotMyFault Thanks for the good links. In one of those threads, there was another link to an article, written by one of the people who was involved in the creation of the JPG algorithm. That link is below and pretty interesting. The "Quality" setting is an arbitrary number and can vary considerably from one program to another. Does anyone know if Affinity uses the IJG JPEG implementation for JPG compression? http://www.faqs.org/faqs/jpeg-faq/part1/section-5.htmlhttp://www.faqs.org/faqs/jpeg-faq/part1/section-5.html Quote 2017 15" MacBook Pro, 16 GB RAM, Ventura v13.7, Affinity Photo/Designer/Publisher v1 & v2, Adobe CS6 Extended, LightRoom v6, Blender, InkScape, Dell 30" Monitor, Canon PRO-100 Printer, i1 Spectrophotometer, i1Publish Link to comment Share on other sites More sharing options...
thomaso Posted April 29 Share Posted April 29 48 minutes ago, Ldina said: The "Quality" setting is an arbitrary number and can vary considerably from one program to another. It seems that's why @NotMyFault posted the links . – At least since Photoshop's values 1-12 (not 0-100%) it might be obvious that there is no absolute unit for jpg quality/compression. – This article, comparing Photoshop/Gimp jpg compression & subsampling may even more surprise: https://blogs.gnome.org/raphael/2007/10/23/mapping-jpeg-compression-levels-between-adobe-photoshop-and-gimp-24/ 38 minutes ago, Ldina said: Does anyone know if Affinity uses the IJG JPEG implementation for JPG compression? Possibly Serif has no interest to publish Affinity code or sources … but a "licenses.rtf" file in the app package might indicate that IJG is involved at least. (and note: it is forbidden to call it "IJG" ;•) Quote Independent JPEG Group The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. This software is copyright (C) 1991-1998, Thomas G. Lane. All Rights Reserved except as specified below. (…) Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software". (…) It appears that the arithmetic coding option of the JPEG spec is covered by patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot legally be used without obtaining one or more licenses. For this reason, support for arithmetic coding has been removed from the free JPEG software. (Since arithmetic coding provides only a marginal gain over the unpatented Huffman mode, it is unlikely that very many implementations will support it.) So far as we are aware, there are no patent restrictions on the remaining code. I wonder what this arithmetic coding option may be? (or has been, considering the age of this article and/or code). Ldina 1 Quote macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1 Link to comment Share on other sites More sharing options...
Oufti Posted April 30 Share Posted April 30 11 hours ago, thomaso said: I wonder what this arithmetic coding option may be? (or has been, considering the age of this article and/or code). According to Wikipedia : Quote Normally, a string of characters is represented using a fixed number of bits per character, as in the ASCII code. When a string is converted to arithmetic encoding, frequently used characters will be stored with fewer bits and not-so-frequently occurring characters will be stored with more bits, resulting in fewer bits used in total. Arithmetic coding differs from other forms of entropy encoding, such as Huffman coding, in that rather than separating the input into component symbols and replacing each with a code, arithmetic coding encodes the entire message into a single number, an arbitrary-precision fraction q, where 0.0 ≤ q < 1.0. walt.farrell 1 Quote Affinity Suite 2.5 – Monterey 12.7.5 – MacBookPro 14" 2021 M1 Pro 16Go/1To I apologise for any approximations in my English. It is not my mother tongue. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.