Skip to content
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
19 changes: 12 additions & 7 deletions Source/FreeImage/PluginWebP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,21 +471,27 @@ 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
// Lossless encoding
config.lossless = 1;
config.quality = 100;
// Size/speed trade-off. Method 0 quality 0 = fastest but largest file-size. Method 6 quality 100 = slowest and smallest file-size.
// NOTE: "quality" in this context is NOT related to anything visual, it purely effects time spent encoding.
config.method = 0;
config.quality = 0;
picture.use_argb = 1;

} else if((flags & 0x7F) > 0) {
// lossy encoding
// Lossy encoding
config.lossless = 0;
// quality is between 1 (smallest file) and 100 (biggest) - default to 75
// Quality/size/speed trade-off (0=fast, 6=slower-better)
config.method = 5;
// Improves color accuracy for the forced 4:2:0 color subsampling in lossy WebP.
// NOTE: In rare cases SharpYUV can cause some colors to become more red.
config.use_sharp_yuv = 1;
// Quality is between 0 (smallest file) and 100 (biggest) - default to 75
config.quality = (float)(flags & 0x7F);
if(config.quality > 100) {
config.quality = 100;
Expand Down Expand Up @@ -701,4 +707,3 @@ InitWEBP(Plugin *plugin, int format_id) {
plugin->supports_icc_profiles_proc = SupportsICCProfiles;
plugin->supports_no_pixels_proc = SupportsNoPixels;
}