mkidd Posted October 16, 2007 Share Posted October 16, 2007 I have read the discussion in the thread viewtopic.php?f=12&t=20431&p=100540&hilit=jpeg#p100540 and understand Rick Brewster's desire not to present an overly complicated quality options for saving JPEG images. However, I would like to suggest an option (a simple check box) to save an image using the same quality settings that were used in the JPEG file originally loaded into Paint.NET (assuming a JPEG was originally loaded). This would allow small edits to be made to a JPEG with minimal degradation without increasing the file size. First, a little background. JPEG quality is actually determined by the Discrete Quantization Tables (DQTs) and optional subsampling factors for each color plane, where the RGB image in transformed into one intensity (Y) and two chrominance (Cr, Cb) planes before the operations involving the DQTs and subsampling are applied. Since each DQT is an 8 x 8 matrix, it is a rare person who can rattle off the exact DQTs that they want. Therefore, the Independent JPEG Group (IJG) came up with a simplified linear quality scale of 0-100 where each integer is mapped to a particular set of DQT tables and subsampling factors. This scheme is implemented by a number of free JPEG read/write utilities and is therefore very common. However, it does not necessarily give the best visual results; it is notable that no digicams nor any Photoshop JPEG image quality settings use this scheme. Thus, there is no JPEG quality setting on the 0-100 simplified scale that accurately reflects what was used to encode most images originally. The upshot is that when a JPEG image originally created by a digicam, Photoshop, or various other programs is modified in Paint.NET, its quality will be degraded if it is saved at quality setting that results in a similar file size. One way around this problem, is to record the DQT and subsampling parameters from the JPEG when it is loaded and use the same exact DQT and subsampling values when resaving the image. A slight bit of numerical roundoff error is inevitable, but the damage is nearly minimized without excessive programming or undue complication of the user interface. Alternatively, there is the optimal solution, but it requires quite a bit more programming. Understand that JPEG images are encoded in 8 x 8 pixel blocks (or 16 x 8, 8 x 16, 16 x 16 etc if subsampling is used). If a JPEG is resaved using the same DQT and subsampling values, the original discrete cosine transform (DCT) values can be imported from the original JPEG for the blocks which have not been altered, i.e. in which no pixel has been altered. Then the damage is both minimized and limited to the regions that are changed. Implementing this requires a detailed unpacking of the original JPEG, comparison of the original JPEG with the image to be saved, and more data manipulation at the DCT level. Though the result would be very nice, it is not simple (I have only seen one commercial Photoshop extension that claims to do it). BTW, if you are truly curious about JPEG innards, you can grab a copy of JPEGsnoop at http://www.impulseadventure.com/photo/j ... ver=0.8.1a). Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.