2

I am using image-webpack-loader to compress images. It works fine with png images, but it's almost not compressing jpeg images.

Example 1:

  • Original PNG file: 124 kb
  • Loader result: 25 kb
  • Tinypng result: 23 kb

Example 2:

  • Original JPG file: 567 kb
  • Loader result: 563 kb
  • Tinypng result: 146 kb

Image loader config: 'image-webpack?{bypassOnDebug: true, progressive: true, optimizationLevel: 1, interlaced: true, pngquant:{quality: 100, nofs: true}}'

How to get close to tinypng result with jpg images?

2 Answers 2

1

According to documentation you need to increase optimizationLevel to higher value (e.g. 5):

The optimization level 0 enables a set of optimization operations that require minimal effort. There will be no changes to image attributes like bit depth or color type, and no recompression of existing IDAT datastreams. The optimization level 1 enables a single IDAT compression trial.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer. But optimizationLevel is applied only to png images. It has no effect at jpeg.
Yep, imagemin-jpegtran have only two options: progressive and arithmetic
0

Try this. It will help you minify jpg images automaticlly without complicated algorithm configurations. It can also help you to encode(and inline) images (behave more flexible than url-loader).

https://github.com/GaoYYYang/image-optimize-loader

module.exports = { module: { rules: [ { test: /\.(png|jpe?g|webp|git|svg|)$/i, use: [ { loader: 'img-optimize-loader', options: { compress: { mode: 'high', } } }, ], }, ], }, }; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.