Giter Club home page Giter Club logo

Comments (13)

kasvtv avatar kasvtv commented on June 5, 2024 3

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...

from responsive-loader.

AlexOuttaspace avatar AlexOuttaspace commented on June 5, 2024 1

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...

I'm currenly solving with imagemin-webpack-plugin. However with it build takes longer.

from responsive-loader.

tettoffensive avatar tettoffensive commented on June 5, 2024 1

@joaocarmo I ended up following the suggestion here: #3 (comment) although it took me a day and a half to get working. Had to fork my own version of the srcset-loader repo and update a few dependencies to get it to build on osx.

from responsive-loader.

tettoffensive avatar tettoffensive commented on June 5, 2024 1

from responsive-loader.

dazuaz avatar dazuaz commented on June 5, 2024 1

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 lovell/sharp#1793 (comment)

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,
    }),
  ],
...

from responsive-loader.

jstcki avatar jstcki commented on June 5, 2024

I don't know how much optimization is actually needed with jimp/sharp but it would be a good idea to support all the output-specific options of either adapter, see http://sharp.dimens.io/en/stable/api-output/

from responsive-loader.

kasvtv avatar kasvtv commented on June 5, 2024

from responsive-loader.

tettoffensive avatar tettoffensive commented on June 5, 2024

I guess this has dropped off, but I have run pngquant -f --ext .png --quality 70-95 *.png on my source images, but when responsive-loader resizes them, they end up much bigger at a comparable image size. Was hoping there was a good solution for this.

from responsive-loader.

joaocarmo avatar joaocarmo commented on June 5, 2024

@tettoffensive , try what @AlexOuttaspace suggested using imagemin-webpack which will optimize all the images that have been handled by the build.

from responsive-loader.

joaocarmo avatar joaocarmo commented on June 5, 2024

@tettoffensive , did you try pwa-srcset-loader? It seems to have a (as of now, at least) somehow recent release.

from responsive-loader.

strarsis avatar strarsis commented on June 5, 2024

Luckily the emitted PNGs are lossless. It is possible to use the webpack imagemin plugin and its test field to have a glob that only matches these PNGs and optimize them using the imagemin png plugins.
This is a different story with lossy formats like JPEG (even with 100% quality) as these are passed as JPEGs through mozjpeg or guetzli and hence can experience an unnecessary additional quality loss.

from responsive-loader.

AaronPorts avatar AaronPorts commented on June 5, 2024

Maybe it makes sense to drop optimization settings and leave it to image-minimizer-webpack-plugin?

from responsive-loader.

dazuaz avatar dazuaz commented on June 5, 2024

Sharp makes it easy to compress jpg/webp/avif, do not think another loader is necessary in the majority of scenarios

from responsive-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.