Giter VIP home page Giter VIP logo

Comments (8)

axe312ger avatar axe312ger commented on June 21, 2024 1

i added example code to the usage section in the readme :)

from metalsmith-sharp.

arggh avatar arggh commented on June 21, 2024

Got it done with this matcher: **/*(!(*@1x)).@(jpg|jpeg|png) and doing a second pass with Sharp, but it makes my build process duration jump from couple of seconds to over a minute.

from metalsmith-sharp.

arggh avatar arggh commented on June 21, 2024

Got the speed back by doing a little tweak, final matcher: **/*(!(*@1x.)+(jpg|jpeg|png)).

Maybe a similar example matcher should be in the docs? (or then I couldn't figure out the "proper" way to accomplish this)

edit: I guess one could also use the metalsmith-branch plugin to achieve this.

from metalsmith-sharp.

axe312ger avatar axe312ger commented on June 21, 2024

See the tests here, where I create multiple versions of one image:
https://github.com/axe312ger/metalsmith-sharp/blob/master/test/index.test.js#L168

Alternatively, you can tell the plugin NOT to move files in the first step, so you do another image manipulation different naming. But calling the plugin twice might extend the compile time.

By default, the image is moved, thats why you had to use such a complex matcher.

See here: https://github.com/axe312ger/metalsmith-sharp#movefile

from metalsmith-sharp.

arggh avatar arggh commented on June 21, 2024

I had disabled moving, the problem was that I didn't know I can do this:

.use(sharp([{
        src: '**/*.@(jpg|png|jpeg)',
        namingPattern: '{dir}/{name}@1x.jpg',
        methods: [{
          name: 'resize',
          args: [768]
        }, {
          name: 'toFormat',
          args: [ 'jpeg' ]
        }],
        moveFile: false
      }, {
        src: '**/*.@(jpg|png|jpeg)',
        namingPattern: '{dir}/{name}@2x.jpg',
        methods: [{
          name: 'resize',
          args: [1536]
        }, {
          name: 'toFormat',
          args: [ 'jpeg' ]
        }],
        moveFile: false
      }]))

So, I would add a section to the docs explaining, that to achieve multiple versions of the same files you can give sharp an array of objects as parameter, instead of only an object.

from metalsmith-sharp.

axe312ger avatar axe312ger commented on June 21, 2024

yes, sure, this is a pretty new feature of the plugin, i missed it in the docs

from metalsmith-sharp.

arggh avatar arggh commented on June 21, 2024

Nice, that should clear things up!

from metalsmith-sharp.

arggh avatar arggh commented on June 21, 2024

Also, thanks for a great plugin :)

from metalsmith-sharp.

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.