-
Notifications
You must be signed in to change notification settings - Fork 19
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
Codec Request: Jpegtran #64
Comments
Brilliant suggestion @jahed. I don't have time to work on this myself. I'd welcome someone to look into providing one and I am happy to help where I can! 🙇 |
Tried building the current jpeg codecs from a default GitHub Codespace, switched to Node 20 to match CI. nvm use 20
cd packages/jpeg/codec
npm run build WASM files are created, but terser via empscripten hits a null pointer.
Could be due to emscripten-core/emscripten#14525 which is fixed. emscripten-core/emscripten#13297 (comment) I noticed there are few old/deprecated versions, like emsdk using Node 14. emsdk@v3 is out. So some version upgrades might help. I'll take another look when I'm ready to integrate this feature. If anyone else wants to, feel free. I'm not familiar with C++/Emscripten or mozjpeg's source so I'd appreciate it. Full build logs (click here)
|
Thanks I believe that error is actually caused by jSquash/packages/jpeg/codec/Makefile Line 24 in 9e7eb88
We can probably use a later emscripten version to bypass that 🤔 Edit: Confirmed Emscripten 3.1.57 seems to work on my local codespace. |
Thanks for taking a look @jahed. Looks like we both added similar fixes at the same time. I've also gone ahead and updated the scripts in the main branch to build it with Emscripten 3.1.57. After playing around further, one observation is that |
Looks like emsdk@v3 can't clean compile mozjpeg. Downgrading back to emsdk@v2 works (with the terser error). config.log shows a permission error which is caused by caches created during the Fixed by setting permissions to the cache files immediately after as suggested here: emscripten-core/emsdk#535 (comment) RUN chmod -R 777 ${EMSDK}/upstream/emscripten/cache Next, it was failing at Click for full config.log.
|
The old version of terser in emsdk@2 is failing at this block (unsupported jSquash/packages/jpeg/codec/pre.js Lines 17 to 19 in 918efc3
If emsdk@v3 is too much effort to upgrade to right now, that block can be removed. Node 18 is the lowest maintained NodeJS version and it supports
Created a PR for that if it's a viable option: |
I also commented in the merge request, but the I think I have solved the compilation issues with emsdk@3 if you pull the latest main branch. |
Is your feature request related to a problem? Please describe.
I'd like to be able to optimise existing JPGs without re-encoding them and losing quality.
Describe the solution you'd like
jpegtran is a popular program to optimise JPGs. It's a part of libjpeg-turbo, so it's also available under mozjpeg. mozjpeg is already used in
@jsquash/jpeg
. So adding anoptimise
function export would make sense, similar to@jsquash/oxipng
.https://github.com/mozilla/mozjpeg/blob/master/jpegtran.c
jpegtran has a bunch of options, I typically use
-optimize -copy none -progressive
.https://github.com/mozilla/mozjpeg/blob/master/jpegtran.1
Describe alternatives you've considered
jSquash is the only actively maintained library I've found that provides oxipng WASM builds with web browser support. It'd be perfect if it also provided a way to optimise JPGs. As far as I can tell, there's no actively maintained package for jpegtran WASM builds or any other package that can optimise JPGs like it can.
Additional context
n/a
The text was updated successfully, but these errors were encountered: