Giter VIP home page Giter VIP logo

Comments (7)

mo271 avatar mo271 commented on September 25, 2024 1

@DejayRezme The problem comes from the fact that for jpeg there is a difference between just storing the pixels losslessly, i.e. distance = 0 and losslessly compressing the bytes of the jpeg file, so that the original jpeg file can be reconstructed. So we need a way to specify a difference between
cjxl -d 0 --lossless_jpeg 1 foo.jpg foo.jxl
and
cjxl -d 0 --lossless_jpeg 0 foo.jpg foo.jxl
(which is probably not what you want)
and
cjxl -d 1 --lossless_jpeg 1 foo.jpg foo.jxl

We tried to make the defaults such that for jpegs lossless recompression of the bytes is the default, because this way no additional artifacts will we introduced, because the operation is reversible.
Do you have concrete suggestions what to change about these defaults?

from libjxl.

mo271 avatar mo271 commented on September 25, 2024

Thanks for the report!

This is intended behavior. In case you are compressing a jpg file, cjxl will by default attempt to compress it as lossless jpeg re-compression and passing a quality parameter will give the error message you are seeing.

It should encode the image with lossy compression when you pass the --lossless_jpeg=0 flag. The default for this flag is "1", since you didn't pass a value for this flag it will be equivalent to passing --lossless_jpeg=1.
I think we could make a better job explaining this in cjxl -h, currently we don't even mention the default setting for this flag

from libjxl.

songjiayang avatar songjiayang commented on September 25, 2024

thanks @mo271 , is --lossless_jpeg a hidden option, I can't find it when run -h

cjxl -h
JPEG XL encoder v0.8.2 [AVX2,SSE4,SSSE3,SSE2]
Usage: cjxl INPUT OUTPUT [OPTIONS...]
 INPUT
    the input can be PNG, APNG, GIF, JPEG, EXR, PPM, PFM, or PGX
 OUTPUT
    the compressed JXL output file
 -d maxError, --distance=maxError
    Max. butteraugli distance, lower = higher quality.
    0.0 = mathematically lossless. Default for already-lossy input (JPEG/GIF).
    1.0 = visually lossless. Default for other input.
    Recommended range: 0.5 .. 3.0. Allowed range: 0.0 ... 25.0.
    Mutually exclusive with --quality.
 -q QUALITY, --quality=QUALITY
    Quality setting (is remapped to --distance).    100 = mathematically lossless. Default for already-lossy input (JPEG/GIF).
    Other input gets encoded as per --distance default,
    which corresponds to quality 90.
    Quality values roughly match libjpeg quality.
    Recommended range: 68 .. 96. Allowed range: 0 .. 100.
    Mutually exclusive with --distance.
 -e EFFORT, --effort=EFFORT
    Encoder effort setting. Range: 1 .. 9.
     Default: 7. Higher number is more effort (slower).
 --brotli_effort=B_EFFORT
    Brotli effort setting. Range: 0 .. 11.
    Default: 9. Higher number is more effort (slower).
 -p, --progressive
    Enable progressive/responsive decoding.
 --resampling=-1|1|2|4|8
    Resampling for extra channels. Default of -1 applies resampling only for low quality. Value 1 does no downsampling (1x1), 2 does 2x2 downsampling, 4 is for 4x4 downsampling, and 8 for 8x8 downsampling.
 -v, --verbose
    Verbose output; can be repeated, also applies to help (!).
 -h, --help
    Prints this help message (use -v to see more options).

from libjxl.

mo271 avatar mo271 commented on September 25, 2024

thanks @mo271 , is --lossless_jpeg a hidden option, I can't find it when run -h

Yeah, that as well, it will show up only when running cjxl -h -v ( with at least one -v). Might it make sense to either show this option already without the -v or put it in the INPUT section like below? What do you think, @jonsneyers ?


JPEG XL encoder v0.8.2 [AVX2,SSE4,SSSE3,SSE2]
Usage: cjxl INPUT OUTPUT [OPTIONS...]
 INPUT
    the input can be PNG, APNG, GIF, JPEG, EXR, PPM, PFM, or PGX.
    If the input is JPEG, then by default lossless recompression will be applied.
 OUTPUT
    the compressed JXL output file

from libjxl.

songjiayang avatar songjiayang commented on September 25, 2024

Copy it, thank you so much.

from libjxl.

DejayRezme avatar DejayRezme commented on September 25, 2024

This broke my ps script for reencoding jpgs.

It seems now every user has to use this more complicated usage and add an if/then/else case into calling cjxl.

I do not see the point as to why - If I specify a distance, it's obvious I do not want lossless. If I specify distance = 0, it's obvious I want lossless. A tool should be as easy and comfortable to use as possible.

Why change the usage suddenly so that other tools or scripts using it break?

from libjxl.

DejayRezme avatar DejayRezme commented on September 25, 2024

Thanks for the reply @mo271

I would suggest that --lossless_jpeg is ignored if distance isn't 0. That someone needs --distance=0 and --lossless_jpeg=0 seems very rare, since the size should always certainly go up.

Or said differently, the default for --lossless_jpeg is 1 if distance=0,
and --lossless_jpeg is 0 (or ignored) if distance > 0

from libjxl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.