Comments (6)
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.
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.
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.
@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.
Hi @lovell
I tried out the quality-option with multiple levels to write a jpeg image, works brilliantly.
Thank you!
from sharp.
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)
- Support outputting higher bit-depth AVIF HOT 1
- Which is better between Sharp.metadata() vs fs.stat() to get image size HOT 1
- Keep only specified EXIF, IPTC, and XMP metadata tag values (similar to `withExifMerge`) HOT 2
- default `limitInputPixels` is not set correctly for jpeg input, avif output, yields `Error: Input image exceeds pixel limit` HOT 2
- sharp: Installation error: Prebuilt libvips 8.14.3 binaries are not yet available for win32-x64 HOT 2
- Using `npm install --cpu=x64 --os=win32` on `arm64/darwin` doesn't install the intended native module. HOT 3
- Google cloud storage integration HOT 1
- Suspect `sharp()....toFile()` do not release input file on Windows. HOT 1
- Conversion from PDF to image HOT 1
- Sharp Crash - libvips_42 - windbg - FAST_FAIL_FATAL_APP_EXIT HOT 8
- munmap_chunk(): invalid pointer, on bun HOT 4
- Consider support for the JPEG-XL format in prebuilt binaries HOT 1
- Not getting density value for tiff files HOT 3
- Output of profile conversion in combination with `negate` seems off HOT 4
- Enhancement: provide API overview in docs HOT 4
- `resize()` does not properly handle `orientation` metadata HOT 4
- Image darkening after updating to 0.32.6 HOT 2
- heif: Unsupported feature: Unsupported codec (4.3000) HOT 20
- png resize artefacts related to premultiplication rounding? HOT 8
- Does not produce image with desired font HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharp.