question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to add png optimization?

See original GitHub issue

I’m aware of the discussion in #3 but it seems that responsive-loader is able to optimize jpegs via the quality setting. Why is it possible to optimize jpegs but not png? Or can optipng and/or pngquant be added? I’d love to be able to handle both jpegs and pngs with this loader.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kasvtvcommented, Jul 31, 2018

Has anyone found a good workflow for minifying the png’s that this plugin creates? It is currently quite a big problem for me, downsizing a 5kB PNG results in a 15kB PNG…

1reaction
dazuazcommented, Aug 14, 2020

Sharp supports PNG optimization only if libvips is compiled with support for libimagequant.

It does not come as default in the bundled libvips binaries that are in the sharp npm package because:

The prebuilt binaries provided by sharp for libvips and its dependencies do not include GPL-licensed or patent-encumbered software.

_Originally posted by @lovell in https://github.com/lovell/sharp/issues/1793#issuecomment-512346455_

To optimize all png images that webpack emits you can use a plugin like imagemin-webpack:

npm install imagemin-webpack imagemin imagemin-pngquant
// webpack config
...
  plugins: [
    new ImageminPlugin({
      test: /\.(png)$/i,
      bail: false, // Ignore errors on corrupted images
      cache: true,
      imageminOptions: {
        // Before using imagemin plugins make sure you have added them in `package.json` (`devDependencies`) and installed them
        // Lossy optimization, check the documentation for other options. 
        plugins: [
          [
            "pngquant",
            {
              quality: [0.6, 0.8],
            },
          ],
        ],
      },
      loader: false,
    }),
  ],
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Optimize PNG - Smashing Magazine
This post describes some techniques that may help you optimize your PNG-images. These techniques are derived from laborious hours spent on ...
Read more >
TinyPNG – Compress WebP, PNG and JPEG images ...
Make your website faster and save bandwidth. TinyPNG optimizes your WebP, PNG and JPEG images by 50-80% while preserving full transparency!
Read more >
How To Optimize Images for Web and Performance - Kinsta
Use PNG if you need high detail and high resolutions. Use JPG for general photos and screenshots. Remove any unneeded image metadata. Automate ......
Read more >
PNG optimization - Optimization - Sirv Help Center
'png.optimize' lets you control PNG optimization with either true/false or 1/0. By default, PNG optimization is enabled for the optimal format (default) ...
Read more >
How to Easily Optimize Images for Web (without Losing Quality)
1. Image File Format. For most website owners, the only three image file formats that really matter are JPEG, PNG, and GIF. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found