Skip to content
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

How set MozJpeg to lossless mode? #344

Open
Alexufo opened this issue Jun 16, 2020 · 4 comments
Open

How set MozJpeg to lossless mode? #344

Alexufo opened this issue Jun 16, 2020 · 4 comments

Comments

@Alexufo
Copy link

Alexufo commented Jun 16, 2020

Since 7.0.0 jpegtran replaced by mozjpeg.
#336

But MozJpeg has only lossy mode. On main page of imagemin:

Comes bundled with the following lossless optimizers:
mozjpeg — Compress JPEG images
...

How I can use MozJpeg in lossless?

@shrpne
Copy link
Contributor

shrpne commented Jul 16, 2020

You can install imagemin-jpegtran back and use it instead of mozjpeg.

But keep in mind that JPEG is lossy format by its nature, so there are rare cases when you really need to compress it losslessly.
Mozjpeg will get you much better compression ratio

@Alexufo
Copy link
Author

Alexufo commented Jul 16, 2020

@shrpne I got a HIGHER file size after MOZjpeg. I compress files in Photoshop and put in folder where mozjpeg add useless data on default 75% quality now. It is a grave mistake to change default behavior of lossless compression to lossy just by one pull request. Documentation is wrong now.

@shrpne
Copy link
Contributor

shrpne commented Jul 16, 2020

I'm sorry that mozjpeg can't reduce filesize after photoshop compression.
To get the best results I don't compress images in Photoshop (export with 100%), and use mozjpeg with jpegtran together.

imagemin([
    mozjpeg(),
    jpegtran({progressive: true}),
])

It will lead to best quality and compression.
If you compare photoshop compression with mozjpeg compression, you will notice, that photoshop produce more artifacts with less compression ratio

Also, documentation will be fixed soon #346 :)

@Alexufo
Copy link
Author

Alexufo commented Jul 17, 2020

MozJpeg has more effective encoder but it less effective if you will set quality by your eyes with PS. In total PS+lossless encode more effective. If you have a lot of images mozjpeg 68% will be good. It much faster for your time. I am waiting when somebody develop algorithm for adaptive encoding when you should not check rate quality/compression by her eyes. In this case mozjpeg with adaptive encoder became as best practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants