7 ms·
Making Photos Smaller Without Quality Loss
- ggambetta 9y ago"MAKING PHOTOS SMALLER WITHOUT QUALITY LOSS" proceeds to explain how they set JPEG quality to 80-85%
- jszymborski 9y agoI don't know it's fair to assume quality means theoretical quality over perceptual quality in this context. They took the time to make sure perceptual quality was quantitatively consistent, so they get a pass in my books. I'd be angry, however, if they used the word "lossless", as that implies no _information_ is lost.
- gknoy 9y agoYou're also overlooking the fact that they did some relatively interesting things to notice when someone posts a PNG-of-something-that-could-be-a-JPEG, and can then use a lossy image instead of the larger PNG.
- ggambetta 9y agoI agree that that's super interesting, but it's not "without quality loss".
- WhitneyLand 9y agoHow is this a big mystery isn't pretty much everything that's user generated content a photo and everything that's a logo or brand not a photo?
- khedoros1 9y agoThey've also got to handle photos with borders, screenshots, and such, which may or may not work better as PNGs. And anyhow, why wouldn't they want to handle un-photo-like photos and un-logo-like logos optimally too?
- abritinthebay 9y agoRead the article. Short answer: no, while your image content breakdowns are accurate it's not actually that simple in practice as things like screenshots are pngs.
- kccqzy 9y agoExactly my thought too. A while ago Dropbox had an article about how they optimized images while making sure the output is bit-for-bit identical. Link: https://blogs.dropbox.com/tech/2016/07/lepton-image-compression-saving-22-losslessly-from-images-at-15mbs/ https://blogs.dropbox.com/tech/2016/07/lepton-image-compress...
- lucideer 9y agoYou misread the article. Setting the JPEG quality is their starting point. He then goes on to describe reducing size from that starting point without further quality loss. Granted, initial reading of the title might lead you to assume he means "from upload quality", but I don't think it's intentionally misleading.
- ge96 9y agoWhat that's what progressive means... where do you select that, is that something you select in say GIMP? >Progressive JPEG images load from more blurry to less blurry. The progressive option can easily be enabled in Pillow What is Pillow, Python... hmm... so loading a small version spread out to full size with blur, then in the background loading full size copy to replace blurred small image, that is not progressive loading...? If I was looking into progressive loading... and implemented a CDN... can this still work? Is it python specific? I use PHP for scripting... maybe an excuse to actually build something with Go rather than the hello world examples. (assuming you can use Go) Edit: also is progressive loading something that happens once or does a script have to do that every time the photo is pulled? What is this a support forum? haha calm down kid
- sp332 9y agoYes, it's one way of storing the image data in a single JPEG file. It doesn't need multiple files and it doesn't need any extra code. It's usually only visible when you're loading the file over a slow link. Old software might not show the intermediate steps from the file but they should still be able to display the image once it's 100% loaded.
- ge96 9y agoThis isn't the same as when you see a photo load with horizontal lines vertically usually top-to-bottom right?
- mysterydip 9y agoBack in the days of slow internet access, nearly every non-animated image was a jpg and loading from blurry to clear was the norm. It's part of the file format.
- mark-r 9y agoThe idea was that you'd see the image get progressively better as each pass was completed, thus the term "progressive". But in practice the browsers decided not to display anything until the image was finished loading anyway.
- mbesto 9y ago> This adds up to an average image file size reduction of around 30%, which we applied to our largest and most common image resolutions, making the website faster for users and saving terabytes a day in data transfer. I love these type of endeavors because the ROI is pretty clear. So what's the costs ($$) savings?
- tehlike 9y agoData transfer is cheap. If they used webp savings would be even significant. Data transfer for a mobile user is not that cheap, thats more important.
- discreditable 9y agoI'm surprised they didn't try losslessly optimizing PNGs with optipng and advancecomp. Optipng in particular can result in some pretty significant size reductions in my experience.
- masklinn 9y agoThey're working with photos, PNG is not really useful for photos, the DEFLATE algorithm doesn't work with "noisy" data.
- pyre 9y agoPresumably the noisiest PNGs were they ones that they converted to JPG in the section "Large PNG Detection."
- discreditable 9y agoThey specifically mentioned that they have PNGs of logos that they avoid converting if they're <300kb. Optipng would work well on the images that they keep in PNG format.
- floatboth 9y agoThey should try just compressing them with mozjpeg anyway, since mozjpeg has deringing https://calendar.perfplanet.com/2014/mozjpeg-3-0/ https://calendar.perfplanet.com/2014/mozjpeg-3-0/ it's actually not bad for text/cartoons/other things with high-contrast edges
- vladdanilov 9y agoSSIM being a global metric is not sufficient for many cases. Images with soft gradient tend to be overcompressed. MozJPEG is a good improvement. But its trellis cost model causes noticeable blurriness on fine details [1]. Compare with the original [2], Guetzli [3] or my Optimage [4]. So, 'Without (Visual) Quality Loss' is such a stretch. [1] http://i.imgur.com/6naOWSf.jpg http://i.imgur.com/6naOWSf.jpg [2] http://i.imgur.com/jny5miJ.jpg http://i.imgur.com/jny5miJ.jpg [3] http://i.imgur.com/gkO2HsP.jpg http://i.imgur.com/gkO2HsP.jpg [4] http://i.imgur.com/GEshKJD.jpg http://i.imgur.com/GEshKJD.jpg
- keymone 9y agoi see literally no difference between all of these. i've stared and flipped through them for a minute.
- khedoros1 9y agoThe biggest difference that I see is that the leaf veins are clearer in the original image than in the other three, and that the MozJPEG one did lose some of the finest details.
- woliveirajr 9y agoSeconded. I can only see differences if I change my monitor settings and zoom the image. So, for the original size as shown without changing configurations from the monitor, there is no clear looser/winner.
- mrob 9y agoAll of them cause noticeable quality loss to the orange anthers of the flower in the top left.
- vladdanilov 9y agoConditions applied: 100% zoom and average viewing distance. The real challenge is consistency. Mozjpeg quality is manually tuned here to match the filesize of the rest.
- mark-r 9y agoWhen I looked at the code for PIL a few years ago, the part I was looking at (resizing) was a real mess with some significant bugs. Has Pillow gotten any better?
- markdown 9y agoWere any of your patches accepted?
- mark-r 9y agoI never bothered, because 1. PIL appeared to be stagnant, 2. without being part of the community I could easily make breaking changes since I judged the existing behavior to be incorrect, and 3. I had other things to do. I have seriously considered going back to see if there's anything I could contribute - I haven't looked at it in years, and it would take a while to identify the code I had looked at before.
- wiredfool 9y agoPillow has had some significant changes in the resampling filters in the last year or two, both in correctness and speed. (PIL is dead. last release was 10 years back)
- js2 9y agoSimilarly at Flickr a couple years ago: http://code.flickr.net/2015/09/25/perceptual-image-compression-at-flickr/ http://code.flickr.net/2015/09/25/perceptual-image-compressi... As well as other changes to reduce storage costs: https://code.flickr.net/2017/01/05/a-year-without-a-byte/ https://code.flickr.net/2017/01/05/a-year-without-a-byte/
- WhiteOwlLion 9y agoWhy not use Google's Guetzli to compress JPEGs?
- 128keaton 9y agoBecause it takes a while for Guetzli to compress
- floatboth 9y agoBecause it's HORRIBLY slow. Mozjpeg is actually usable for on-the-fly processing, you can run it right in a request handler. Guetzli is waaaay too slow.
- dawidloubser 9y agoAgreed. As a photographer, I use and love Guetzli, and it offers a bona fide size reduction of more than 30% over typical JPEG compression algorithms at a similar visual quality level. But it's extremely computationally-intensive, taking over a minute to compress a single web-resolution image on my i7 laptop. I can't see it being practical in a high-volume server scenario.
- thebostik 9y ago(author here), It wasn't available when I started this project. butteraugli was (which guetzli uses internally), but in my opinion they're relatively new and need a bit more rigorous review than I can provide. I ultimately chose SSIM not because it was the most accurate metric in all cases, there have been plenty of advancements since it was published. But I linked a paper comparing several alternatives and saw that SSIM works fine for this use case (all things equal except number of JPEG artifacts), while being much faster, and that was enough proof for me to keep it simple. In a batch scenario today, one of these could make sense instead of SSIM and/or mozjpeg, but definitely do your own comparisons at equivalent file sizes, required reading: https://kornel.ski/en/faircomparison https://kornel.ski/en/faircomparison We do set a pretty high lower bound to avoid the edge cases inherent in the algorithm and as a result, out of the 30% savings, dynamic quality was only a small portion of that. I wouldn't be surprised that with an offline workload, a more CPU-intensive algorithm can do much better with a lower lower bound. I found that SSIM scores for images were relatively stable across resolution (same general graph shape, just translated down on the Y-axis). This is mentioned at line 36 of the example dynamic quality code. So we actually generate, compute and compare the SSIMs on much lower resolution candidate images than the final image for speed as well. I'm not sure if this would hold true for something like butteraugli to help open up the possibility for more real-time workloads.
- dabber 9y agoHmm, I'm behind a popular VPN and get greeted with: "Sorry, you’re not allowed to access this page." "Contact Yelp if you keep experiencing issues." Oh well
- kemonocode 9y agoIt took me a shameful amount of time to realize the peppered 400: Invalid request's through the article were unintended.
- acranox 9y agoI think that photo of a "donut" is actually a bagel.