Search code examples
node.jsimportecmascript-6graphicsmagick

How to import node module passing subClass argument in ES6?


In JS I require in the node module gm (which I want to use with imageMagick rather than the default graphicsMagick) while passing an argument like this:

 var gm = require('gm').subClass({ imageMagick: true });

How can I do that in ES6?

import gm from "gm";
gm.subClass({ imageMagick: true });

doesn't work, because gm defaults to GraphicsMagick which isn't installed.


Solution

  • Answer from @Felix Kling works:

    import gm from "gm";
    const im = gm.subClass({ imageMagick: true });
    

    ...using im from here on!