GithubHelp home page GithubHelp logo

Jpeg Image Quality about sharp HOT 6 CLOSED

lovell avatar lovell commented on May 13, 2024
Jpeg Image Quality

from sharp.

Comments (6)

pierreinglebert avatar pierreinglebert commented on May 13, 2024

It's hard coded here https://github.com/lovell/sharp/blob/master/src/sharp.cc#L262 and https://github.com/lovell/sharp/blob/master/src/sharp.cc#L277

from sharp.

lovell avatar lovell commented on May 13, 2024

Hi @KevinJaspal, thanks for the kind words.

As @pierreinglebert says, JPEG quality is currently fixed at 80%. If it's good enough for Wikipedia then its good enough for us 😄

More seriously, I'd be happy to expose quality as an optional setting in the range 1-100, with a sensible default (perhaps the current value of 80 for backwards compatibility).

This option would apply to the lossy formats of JPEG, WebP and TIFF (uses JPEG under the hood).

For the lossless PNG format, accepting an optional compression value makes more sense as the underlying zlib library takes an compression value of between -1 and 9. (I'm not a fan of the way GraphicsMagick overloads the concept of "quality" to set lossless PNG compression level - the quality remains the same).

from sharp.

KevinJaspal avatar KevinJaspal commented on May 13, 2024

Thanks for the prompt response @pierreinglebert and @lovell :)

I think having a default 80 quality setting with an optional setting that can be specified would be perfect. That way you can maintain backwards compatibility, keep the api simple to use for the majority of users and still provide the flexibility for adjusting the value.

Having an optional compression value for PNG definitely makes more sense than quality.

👍

from sharp.

lovell avatar lovell commented on May 13, 2024

@KevinJaspal please can you take a look at the API additions on the quality-option branch and let me know if they work for you.

from sharp.

KevinJaspal avatar KevinJaspal commented on May 13, 2024

Hi @lovell

I tried out the quality-option with multiple levels to write a jpeg image, works brilliantly.

Thank you!

from sharp.

lovell avatar lovell commented on May 13, 2024

No problem, thank you for helping test. This is now merged to master and will be included in v0.4.0.

from sharp.

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.