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

Slightly refactor/fix/change/improve WebP config #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Source/FreeImage/PluginWebP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,20 +471,26 @@ EncodeImage(FIMEMORY *hmem, FIBITMAP *dib, int flags) {
WebPConfigInit(&config);

config.thread_level = 1;
// quality/speed trade-off (0=fast, 6=slower-better)
config.method = 0;

config.exact = (flags & WEBP_EXACT) == WEBP_EXACT;

if((flags & WEBP_LOSSLESS) == WEBP_LOSSLESS) {
// lossless encoding
config.lossless = 1;
config.quality = 100;
// size/speed trade-off (method 0 and quality 0 = lowest effort but largest file-size while method 6 and quality 100 = highest effort and smallest file-size. NOTE: "quality" in this context is NOT related to anything visual)
config.method = 4;
config.quality = 50;

picture.use_argb = 1;

} else if((flags & 0x7F) > 0) {
// lossy encoding
config.lossless = 0;
// quality/speed trade-off (0=fast, 6=slower-better)
config.method = 5;
//config.autofilter = 1; // improves lossy quality but is NOTICEABLY slower
config.use_sharp_yuv = 1; // "config.preprocessing = 4;" is the old/alternative way to activate SharpYUV. NOTE: in some rare'ish cases SharpYUV can cause some colors to be more red then they should be

// quality is between 1 (smallest file) and 100 (biggest) - default to 75
config.quality = (float)(flags & 0x7F);
if(config.quality > 100) {
Expand Down