-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential of jpegli to optimize existing JPEG files #10
Comments
I don't think there is much to be gained from rewriting EDIT: Rereading your issue, I realized it was a question of whether jpegli had the capability "to optimize jpeg files" rather than a demand for a new feature (lossless jpeg recompression). Sorry for the mix-up, I was tired at work when I wrote this. To answer your question of "optimizing jpeg files without visually losing quality". Yes, If you don't want generation loss, then no, jpegli can't make mathematically lossless jpegs (not even at distance 0). You can refer to my first statement, using jpegtran or jxl results in an image that is identical to the original while taking up less space. |
(Despite what GitHub thinks, I have not contributed to libjpegli. Once upon a time, I had some PRs to libjxl. That code has probably been excised from this repo.) |
Thanks guys for your answers. Anyway, metadata is lost by this way of optimizing a existing JPG file too. Yeah, there is JPEG XL, but I want to stick with good old JPG files, at least for now. |
What's wrong with jpegxl? For archiving/storing photos it's great. The only setback is web delivery since most browsers don't support it yet.
This is also a limitation of libjpeg/mozjpeg as well. Libjpeg/mozjpeg defaults to 4:4:4 subsampling at qualities ≥ 90, 4:2:2 subsampling at qualities 80-89, and everything lower than that is 4:2:0. That was quite a shock to me since at the time I just assumed it was all 4:4:4 and you had to manually set 4:2:0. Nevertheless I agree, it would be a nice feature to have.
It's not fixed like a typical quality setting, there is a quality slider but it's mapped to distance (e.g., quality 90 corresponds to distance 1), and it doesn't function the same as libjpeg. The difference with jpegli lies in how quality is tied to a measured distortion of the image. This distortion is measured using butteraugli, a metric representing human vision. This method is superior because ‘quality’ is subjective and varies depending on the image. For example, in libjpeg, some images look fine at quality 75 while others look awful at quality 90 because it treats all images the same. Jpegli's goal is to achieve a target quality specific to each image. So, at distance 3, all images will appear low quality, while at distance 2, they’ll be medium quality, and so on. This adaptive approach eliminates the need for manual adjustments of the quality silder, I just set a target quality and let it do it's magic. It's an underrated feature of jpegli.
This is a non issue, this "problem" appears in all lossy formats. I often hear similar sentiments with video, "I re-encoded a video at a higher quality setting than it was recorded. Why it larger than original?" It's a rookie mistake, trust me, I've been there . The default distance of 1 is considered to be "high quality." This differs from libjpeg/mozjpeg which defaults to a quality of 75 (which I would consider "medium quality"). You encoded that same image with a higher quality than the original jpeg, of course it's going to be larger! The only thing you did was add generation loss. The phenomenon can happen with any lossy image/video format. If there is one concession I can make, maybe the YUV 4:4:4 subsampling is bloating the image size, try again with the flag
That's just the default, you can change it however to suit your needs. I don't seem to understand your use case. If you are adamant that jpg is the only way to store images, then just use jpegtran, it also preserves metadata and it doesn't further degrade the image. If you are talking about web delivery and you don't want to use AVIF, I would recommend |
jpegli is pretty new. Depending on how actively it's developed, the issues you're having may be resolved in the future. Consider opening separate issues focused on isolated problems that could be implemented separately. Maybe don't open too many all at once, to avoid flooding developers. May also be beneficial to wait a while for them to complete housekeeping from switching to a new repo. For now, you could take a look at |
Hello. I share photos of family parties with family members. I send photos of the parties to members who don't have time or cannot participate at the parties via e-mail. But I have a workable solution to optimize my photos. The solution I had in mind is more a general approach to it, but it's more like a nice to have solution. |
I've tried that, but it makes no difference. The version of cjpegli I have at hand doesn't show jpg in the help text |
Strange... if I run
No JPEG listed. And if I try to use a ".jpg" as input, I get this:
I was now wondering why wouldn't cjpegli support JPG as input, which seems counterintuitive. And then I found this Issue thread. Is this because of the way I built, or has cjpegli input support changed over time? This is how I'm building, on an Alpine in docker:
|
Alright... looks like I had a few dependencies missing... Once I added these:
I now see the full list:
|
https://github.com/google/jpegli/blob/main/README.md#encoder-improvements (last §) notes that it has compression optimizations for a certain subclass of jpg. Is that lossless, @ least?
|
No, XYB jpegs are lossy. More efficient compression than regular jpegs but still a lossy process. Jpegli is not a transcoder like |
I'd like to know if jpegli has potential to optimize the size of already existing JPEG files without loosing quality visual wise. (created by libjpeg or mozjpeg)
The text was updated successfully, but these errors were encountered: