Giter VIP home page Giter VIP logo

magickwand.js's Introduction

magickwand.js

ISC Test npm package Node.js CI npm

formerly known as node-magickwand

This package is a full native port of the ImageMagick-7 C++ library to both Node.js native and browser WASM using SWIG Node-API + emnapi.

Unlike all other ImageMagick npm packages, it does not use the CLI to interact with the utilities, but offers direct access to the full C++ API. It supports both synchronous and multithreaded asynchronous operations, it is integrated with TypedArrays and ArrayBuffer and it has full TypeScript support.

It adds many new features and offers a substantial performance boost and usability benefits over the previous CLI ports.

The Node.js native addon version and the browser WASM version share the same SWIG interface files, the same generated C++ wrappers, the same API, the same TypeScript bindings and the same unit tests which are run both in the browser and in Node.js. Both support asynchronous parallel processing using the same multi-threading model.

The pre-built binaries are fully self-contained and do not need an existing ImageMagick installation. It is also possible to rebuild the package against a shared ImageMagick-7 when using the native version in Node.js.

The default WASM version is also fully self-contained and its size range is from 1.5MB (minimal, compressed w/ brotli) to 5MB (default full build compressed w/ gzip) depending on the supported image formats.

Both versions support synchronous and asynchronous multi-threaded operations with an identical API and identical TypeScript bindings. WASM requires SharedArrayBuffer (read about COOP / COEP). The Node.js native version also support OpenMP multithreading and SIMD instructions.

The project is currently to be considered of beta quality, but it is actively developed and maintained because of it its special status as SWIG Node-API showcase project. It is a testament to SWIG Node-API's capabilities, namely producing a 400k C++ lines multi-threaded and dual-environment project out of 600 lines of SWIG code.

It is feature-complete and it should be reasonably stable. The Node.js native version is designed to be well-suited for server-side use with an Express.js-like framework. It has been debugged for memory leaks and, and when only asynchronous methods are used, it should never block the event loop. See also Security.

There is also a medium article about using the new Node-API support in SWIG in case you are interested in porting another C++ library to Node.js.

Usage

npm install magickwand.js

This will install pre-built Node.js native binaries on Windows x64, Linux x64 and macOS x64. It will try to compile the module on all other platforms. It will also install the pre-built WASM binaries which are universal.

Refer to the example directory for more code examples including browser use examples.

Refer to the test/integration directory for integration examples with various environments including webpack and TypeScript.

Using from Node.js (native module)

import { Magick } from 'magickwand.js';
import { fileURLToPath } from 'url';
import * as path from 'path';

// The famous ImageMagick wizard
const wizard = path.join(path.dirname(fileURLToPath(import.meta.url)),
  'node_modules', 'magickwand.js', 'test', 'data', 'wizard.png');

// Read a new image (synchronously)
let im = new Magick.Image(wizard);
console.log(`${wizard}: ${im.size()}`);

// Read a new image (asynchronously)
im = new Magick.Image;
await im.readAsync(wizard);
console.log(`${wizard}: ${await im.sizeAsync()}`);

// Convert it to PNG
await im.magickAsync('PNG');

// Rescale and rotate it
await im.scaleAsync('160x212');
await im.rotateAsync(60);

// Extract the RGBA data
// Conversion to Uint16 is automatic (it recognizes the type of the array)
const pixels = new Uint16Array(im.size().width() * im.size().height() * 4);
await im.writeAsync(0, 0, im.size().width(), im.size().height(), 'RGBA', pixels);

Using in the browser (WASM module)

To see run the web browser example:

npm run example:browser

Then open http://localhost:8030.

There is also an online demo at https://magickwand.momtchev.com/.

You can run it locally with:

npm run demo:start

Documentation

Your best source of further information is the Magick++ documentation itself:

magickwand.js implements the full Magick++ C++ API.

(only the Pixels and PixelData classes are not implemented in JavaScript - use Image.pixelColor to get individual pixels or write the image to a TypedArray with RGB/RGBA/CMYK encoding to get a large region).

Also, if you have a code editor capable of reading the TypeScript bindings, such as Visual Studio Code, it will provide online help for each method.

When in doubt about the JS semantics of a particular method, you can also check the unit tests: https://github.com/mmomtchev/magickwand.js/tree/main/test.

When using Node.js with X-Windows, the Image.display() function works and it is an excellent debugging tool.

Rebuilding from npm with the built-in ImageMagick library

npm install magickwand.js --build-from-source

You will need a working C++11 environment.

On Windows nothing but VS 2022 works at the moment. This will also rebuild the included Magick++ library.

On Linux and macOS it uses pip3 to install the conan module which builds a number of required libraries in ${HOME}/.conan. After building, you can safely delete this directory if you wish, since magickwand.js is statically linked.

Rebuilding from git or using an externally provided ImageMagick library

  • In order to regenerate the C++ wrapping code, you will need SWIG JavaScript Evolution 5.0.0 - available from https://github.com/mmomtchev/swig.git (as of 2024-01-18, the basic Node-API has been merged to the main SWIG trunk, the async support is in review, everything else is available only in SWIG JSE)

  • Alternatively, if you don't want to rebuild SWIG JSE yourself, you can clone the generated branch where all files have been pre-generated - npm run deps:download does this automatically after npm install

  • Recursively clone the repo

git clone --recursive https://github.com/mmomtchev/magickwand.js
cd magickwand.js
  • npm install should automatically install the dependencies and compile the module unless a pre-built binary can be downloaded

  • or, to do everything manually:

npm install --ignore-scripts
npm run deps:download
npx @mapbox/node-pre-gyp configure   # --debug for debug mode
npx @mapbox/node-pre-gyp build

Alternatively, you can use an already installed on your system ImageMagick-7 library. In this case you should know that there are two compilation options that can produce four different libraries - enabling/disabling HDRI (High Dynamic Range Images) which returns float pixels instead of int and Q8/Q16 which determines the bit size of the Quantum. These only apply to the data used internally by ImageMagick - image files still use whatever is specified. Mismatching those will produce an addon that returns garbage when requesting individual pixels. By default, this addon uses Q16 with HDRI - which is the default setting on Linux. Unless you can regenerate the SWIG wrappers, you will have to use the exact same version (the latest one at the release date) that was used when they were generated. In this case, assuming that you have ImageMagick installed in /usr/local, build with:

npx @mapbox/node-pre-gyp configure --shared_imagemagick

LDFLAGS=-L/usr/local/lib \
CFLAGS=-I/usr/local/include/ImageMagick-7 \
CXXFLAGS=-I/usr/local/include/ImageMagick-7 \
npx @mapbox/node-pre-gyp build \
--magicklibs="-lMagick++-7.Q16HDRI -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI"

Or when directly installing with rebuilding from npm:

LDFLAGS=-L/usr/local/lib \
CFLAGS=-I/usr/local/include/ImageMagick-7 \
CXXFLAGS=-I/usr/local/include/ImageMagick-7 \
npm install magickwand.js --build-from-source --shared_imagemagick \
--magicklibs="-lMagick++-7.Q16HDRI -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI"

In this case, it would be possible to use a non Q16HDRI build or any other specially built ImageMagick-7 as long as its version is an exact match.

If you want to use a different ImageMagick-7 version, you will have to regenerate the SWIG wrappers. You will have to have to build yourself SWIG 4.2.0-mmom from https://github.com/mmomtchev/swig/tree/mmom and then run

npm run swig
  • npm test should work at this point

Rebuilding the WASM version

The WASM version uses SWIG JSE and emnapi.

Generally, the prebuilt WASM binaries should work for everyone. Currently, npm install is not capable of rebuilding it. To rebuild the WASM version yourself, you should start by building the conan dependencies:

npm run conan:emscripten

Or to build a minimal version that excludes many optional dependencies:

npm run conan:emscripten --                                               \
  -ofonts=False -ojpeg=True -opng=False -otiff=False                      \
  -owebp=False -ojpeg2000=False -oraw=False -oopenmedia=False             \
  -obrotli=False -oh265=False -oexr=False -offtw=False -oheif=False       \
  -ojbig=True -ocolor=False -oxml=False -ogzip=False -ozip=False            \
  -obzip2=True -ozstd=False -oxz=False -olzma=False -osimd=False          \
  -oopenmp=True -odisplay=False

Then launch:

npm run configure:emscripten
node-pre-gyp build

At the moment this cross-compilation has been tested only on Linux.

Keep in mind that if you want to switch between building a native and a WASM version, you should do:

rm -rf build
cd deps/ImageMagick
make distclean

Otherwise, in between conan, gyp and the ImageMagick's own build, you might run into weird dependency problems.

Building a light version

Building a lighter custom binary which does not include some of the builtin libraries is possible by specifying:

npm install --build-from-source --verbose \
    --fonts=false --jpeg=false --png=false --tiff=false \
    --webp=false --jpeg2000=false --raw=false --openmedia=false \
    --brotli=false --h265=false --exr=false --fftw=false --heif=false \
    --jbig=false --color=false --xml=false --gzip=false --zip=false \
    --bzip2=false --zstd=false --xz=false --lzma=false --simd=false \
    --openmp=false --display=false

This is not supported for the Windows build which is monolithic. It is supported for Linux, macOS and WASM (see above for WASM). It disables the included delegates, but keep in mind that on Linux and macOS, the ImageMagick configure script will still detect the presence of some system libraries (jpeg, bzip2, jbig and OpenMP) and will try to use them, producing a binary that will need the dynamically loaded versions of those libraries on your system. This is not a problem with the WASM version as it is very unlikely that you will have system-installed WASM-version libraries that ImageMagick will detect and use.

If the WASM binary is rebuilt with no additional libraries, its size will be brought down to 1.5MB compressed with brotli. Further reduction is possible by disabling unneeded SWIG wrappers but this requires to manually edit the SWIG source files and to regenerate the C++ files. Producing a version that supports only synchronous mode and does not require COOP/COEP is also possible. I will consider any offer for commercial support of such dedicated light version.

Using this project as a tutorial for creating C++ bindings for Node.js and emscripten/WASM with SWIG Node-API

ImageMagick is the perfect candidate for an automatically generated with SWIG Node.js addon:

ImageMagick has an absolutely huge number of API methods and objects - the SWIG-generated module totals more than 400k lines of C++ code - and this is only covering the Magick++ API and the enums from the MagickWand API. However there are relatively few distinct method signatures. The whole SWIG project which brings you this full API to Node.js and the browser, measures a grand total of only 656 lines - half of which are comments!!

I have tried to be as verbose as possible throughout the Magick++.i file - you should start there. ImageMagick is a very complex C++ project with over 30 years history and it uses (almost) every single SWIG feature. Study the various JS wrappers that expect special arguments (ArrayBuffer, TypedArray, arrays), remember to check the ImageMagick header file for the original C++ function and you should be able to use its SWIG typemaps as a starting point in your project.

There is also a medium article about using the new Node-API support in SWIG.

Current status of SWIG Node-API as of 2023-10-22:

Feature Status Documentation
Base Node-API support merged, scheduled for 4.2.0 Part of the official SWIG 4.2.0 documentation
Asynchronous methods swig/PR#2654 in review Part of the official SWIG documentation (in swig/PR#2654)
TypeScript support mmomtchev/swig#typescript, polishing for PR Ony the medium story
WASM / emscripten / emnapi compatibility mmomtchev/swig#wasm, mostly working None at all
Code Splitting mmomtchev/swig#mmom, Proof of Concept None at all

SWIG checked out from https://github.com/mmomtchev/swig/tree/mmom is the only version that can generate this project. Besides the above features, it contains several additional small patches some which are still under discussion - such as applying %feature to a class.

Known to be broken at the moment

  • Regenerating the SWIG bindings is possible only with my own unpublished SWIG checked out from Github
  • Rebuilding when installing requires Node.js >= 18.0 on all platforms
  • Additionally, rebuilding when installing on Windows works only with VS 2022
  • The debug build on Windows requires manually setting winbuildtype and winbuildid due to restrictions in gyp
  • The Node.js native module supports worker_threads but it cannot be unloaded cleanly and it should be loaded in the main thread, before using it in worker threads, to prevent Node.js from unloading it when a worker quits (fixing this will require changes in Node.js)
  • Building on Windows without HDRI enabled or with a different quantum size than 16 bits is not supported
  • If rebuilding when installing from npm fails on Windows with the error: npm ERR! fatal: not a git repository (or any of the parent directories): .git, see #21
  • Fonts do not work in the WASM version and are unlikely to be implemented in the near future as a proper implementation will require a complex interface with the browser font engine
  • Using the PNG encoder for large images in the WASM version leads to stack overflows, the native version encoder and the WASM decoder work fine
  • Generally, if you get strange exceptions in the WASM code, the most probable reason is a stack overflow - currently, emscripten cannot grow the stack which is limited to 2MB and cannot reliably report stack overflows without incurring a significant performance penalty
  • The loader of the WASM version has its Node.js support disabled to improve its webpack compatibility - as Node.js has its own native version, there is no need for WASM

Future plans

This project serves as showcase and testing grounds for SWIG Node-API.

SWIG Node-API roadmap:

  • a wasi-wasm32 target in addition to the emscripten-wasm32 target
  • a much slower for async operations but more compatible WASM version that does not require COOP/COEP but uses message passing between web browser threads
  • Direct implicit casting of objects, avoiding the special handling of Geometry and Color
  • Automatic transparent handling of ArrayBuffers in a way that hides any differences between the Node.js native and the browser WASM environment
  • Improved STL containers support avoiding the need for special handling of methods that require std::vector support
  • Regexp support for %feature avoiding the need to explicitly list all the async classes
  • Provide memory allocation information to the GC

magickwand.js roadmap:

  • SIMD support for the WASM version
  • Allow configuration from the CLI of the included wrappers - allowing to build an ultra-light version that includes support only for the methods selected by the user

Security

ImageMagick is a very widely used software. Security vulnerabilities tend to be very well known and are usually fixed very fast.

The current ImageMagick version can be checked in the MagickLibVersionText / MagickLibAddendum global exported constants.


IMPORTANT

  • Versions of magickwand.js up to 0.9.6 including are compiled with a libwebp vulnerable to CVE-2023-4863.

  • Prebuilt binaries of magickwand.js are NOT affected by CVE-2024-3094 since these are linked with xz-utils 5.4.5, the last version before the backdoor.


Special care must be exercised when ImageMagick is used to process images coming from untrusted sources. Although possible, outright arbitrary code execution by embedded malicious code in an image is extremely rare and there has been only one such case during the last 30 years - the infamous ImageTragick exploit in 2016. It did not affect users who had restrictive security policies.

However DoS attacks are much more common as it is relatively easy to construct an image that will be of relatively small size when compressed, but it will expand to fill all available memory once uncompressed.

If using ImageMagick in such environment, it is highly recommended to review the default security policy in node_modules/magickwand.js/lib/binding/{platform}/ImageMagick/etc/ImageMagick-7/policy.xml and to eventually replace it with a more restrictive security policy from the examples in node_modules/magickwand.js/deps/ImageMagick/config/. Be also sure to check https://imagemagick.org/script/security-policy.php for more information and to follow an appropriate security announcements mailing list. Also, consider re-building ImageMagick yourself in order to support a more limited amount of image file formats, as complexity is always the main risk factor with any software.

Example for loading websafe (the most restrictive security policy):

const pathNodeMagick = require.resolve('magickwand.js');
const websafe = fs.readFileSync(path.resolve(pathNodeMagick,
  'deps', 'ImageMagick', 'config', 'policy-websafe.xml'), 'utf8');
Magick.SetSecurityPolicy(websafe);

assert(MagickCore.IsRightsAuthorized(
  MagickCore.SystemPolicyDomain,
  MagickCore.WritePolicyRights, 'file') === false);

The current security policy can be dumped to stdout by calling MagickCore.ListPolicyInfo(). There is also an online tool for analyzing security policies at https://imagemagick-secevaluator.doyensec.com/.

In all other cases security should not be of any concern.

License

Copyright 2023 Momtchil Momtchev [email protected]

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Disclaimer

magickwand.js is not affiliated in any way with ImageMagick LLC.

In particular, the WASM version is an independent and distinct port from the WASM port of one of the ImageMagick authors.

magickwand.js's People

Contributors

dependabot[bot] avatar mmomtchev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

magickwand.js's Issues

Cannot use in MacOS arm64

I installed, imported and used like you specified in document. But when I run I got this error:

$> node index.js
node:internal/modules/cjs/loader:1048
  const err = new Error(message);
              ^

Error: Cannot find module '/Users/thanh_da/Documents/im_nodejs/node_modules/magickwand.js/lib/binding/darwin-arm64/magickwand.node'
Require stack:
- /Users/thanh_da/Documents/im_nodejs/node_modules/magickwand.js/lib/index.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/Users/thanh_da/Documents/im_nodejs/node_modules/magickwand.js/lib/index.cjs:21:13)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at cjsLoader (node:internal/modules/esm/translators:284:17) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/thanh_da/Documents/im_nodejs/node_modules/magickwand.js/lib/index.cjs'
  ]
}

Node.js v20.9.0

This is the only code that use the lib

import { Magick } from "magickwand.js";

const resize = async (imageArrayBuffer, specification) => {
	const wizard = new Magick.Blob(imageArrayBuffer);
	console.log("Before transfrom", wizard.length);
	const im = new Magick.Image();
	await im.readAsync(wizard);
	return await im.resize(specification).then(() => wizard.data);
};

Can someone please explain to me, is this a library error or did I do something wrong?

This is my package.json

{
  "name": "lambda-image",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@aws-sdk/client-s3": "^3.454.0",
    "axios": "^1.6.2",
    "file-type": "^18.7.0",
    "magickwand.js": "^1.0.0-beta.6"
  }
}

Fail to install on MAC OS node 18 / 16 / 14

npm install node-magickwand --build-from-source

npm ERR! code 1
npm ERR! path /Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build && node scripts/gen-es6.js lib/index.mjs
npm ERR! Failed to execute '/Users/macuser/.nvm/versions/node/v18.14.0/bin/node /Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/lib/binding/darwin-x64/node-magickwand.node --module_name=node-magickwand --module_path=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/lib/binding/darwin-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | x64
npm ERR! node-pre-gyp info build requesting source compile
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.2 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/macuser/Library/Caches/node-gyp/18.14.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/macuser/Library/Caches/node-gyp/18.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/macuser/Library/Caches/node-gyp/18.14.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/3.8/site-packages/pygments'
npm ERR! Consider using the `--user` option or check the permissions.
npm ERR! 
npm ERR! WARNING: You are using pip version 19.2.3, however version 23.2.1 is available.
npm ERR! You should consider upgrading via the 'pip install --upgrade pip' command.
npm ERR! gyp: Call to '(pip3 install "conan<2.0.0" && cd build && conan install .. -pr:b=default -of build --build=missing --build=openjpeg) > /dev/null' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:325:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 19.6.0
npm ERR! gyp ERR! command "/Users/macuser/.nvm/versions/node/v18.14.0/bin/node" "/Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/lib/binding/darwin-x64/node-magickwand.node" "--module_name=node-magickwand" "--module_path=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/lib/binding/darwin-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
npm ERR! gyp ERR! cwd /Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand
npm ERR! gyp ERR! node -v v18.14.0
npm ERR! gyp ERR! node-gyp -v v9.3.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/macuser/.nvm/versions/node/v18.14.0/bin/node /Users/macuser/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/lib/binding/darwin-x64/node-magickwand.node --module_name=node-magickwand --module_path=/Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand/lib/binding/darwin-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/macuser/practices/imageCompression/magick/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Darwin 19.6.0
npm ERR! node-pre-gyp ERR! command "/Users/macuser/.nvm/versions/node/v18.14.0/bin/node" "/Users/macuser/practices/imageCompression/magick/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/macuser/practices/imageCompression/magick/node_modules/node-magickwand
npm ERR! node-pre-gyp ERR! node -v v18.14.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/macuser/.npm/_logs/2023-10-05T19_36_22_455Z-debug-0.log

Rebuilding when installing from npm is broken on 0.9.0

Caused by the fix of #7

Run npm install --force [email protected] --build-from-source
npm WARN using --force Recommended protections disabled.
npm ERR! code 1
npm ERR! path /home/runner/work/node-magickwand/node-magickwand/node_modules/node-magickwand
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build && npx copyfiles -sf swig/*.d.ts lib
npm ERR! Failed to execute '/opt/hostedtoolcache/node/18.17.1/x6[4](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:5)/bin/node /opt/hostedtoolcache/node/18.17.1/x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/runner/work/node-magickwand/node-magickwand/node_modules/node-magickwand/lib/binding/linux-x64/node-magickwand.node --module_name=node-magickwand --module_path=/home/runner/work/node-magickwand/node-magickwand/node_modules/node-magickwand/lib/binding/linux-x64 --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | linux | x64
npm ERR! node-pre-gyp info build requesting source compile
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v18.17.1/node-v18.17.1-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.17.1/node-v18.17.1-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v18.17.1/SHASUMS2[5](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:6)[6](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:7).txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.1[7](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:8).1/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/hostedtoolcache/node/1[8](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:9).[17](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:18).1/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/work/node-magickwand/node-magickwand/node_modules/node-magickwand/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/hostedtoolcache/node/[18](https://github.com/mmomtchev/node-magickwand/actions/runs/6186789692/job/16795209879#step:7:19).17.1/x64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/.cache/node-gyp/18.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/runner/.cache/node-gyp/18.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/hostedtoolcache/node/18.17.1/x64/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/runner/.cache/node-gyp/18.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/runner/work/node-magickwand/node-magickwand/node_modules/node-magickwand',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: node_modules/node-addon-api/except.gypi not found (cwd: /home/runner/work/node-magickwand/node-magickwand/node_modules/node-magickwand) while reading includes of binding.gyp while trying to load binding.gyp

Faile to new Image in x86 macOS, node version 20.12.1

Hello author, I have encountered some error that make the project can not proceed normally, so I have to come here for help.

After I installed node-magickwand via npm on an x86 mac, I executed the following code:

const { Magick } = require('magickwand.js')
async function main() {
    const filePath = '/Users/deadfish/Documents/project/deadfish/Photography2Client/testFiles/DSC_6880.NEF'
    const largeWand = new Magick.Image(filePath)
}
main()

And here is the error information:

/test.js:4
    const largeWand = new Magick.Image(filePath)
                      ^

Error: node: unable to open image '/var/folders/s7/h94j1mz54_bd7ss0xk1h891r0000gn/T/magick-u16WoVnI3F6lzl0HbDLctNjtbwfzfrTU.ppm': No such file or directory @ error/blob.c/OpenBlob/3571
    at main (/Users/deadfish/Documents/project/deadfish/Photography2Client/p2p-pick/photographyClient/test.js:4:23)
    at Object.<anonymous> (/Users/deadfish/Documents/project/deadfish/Photography2Client/p2p-pick/photographyClient/test.js:7:1)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.12.1

It works fine on windows, but faile on macOS, version Monterry 12.6.2(21G320).

I understand that I can use magick in software by calling system commands, but this is too cumbersome for the user, so hopefully We can find the cause of this error.

Converting a Multi-Page-PDF to multiple PNG files

Hello,

I wanted to use node-magickwand to convert a PDF to separate PNG files.
In a terminal using the imagemagick cmd tool I can do this:
convert -density 150 in.pdf PNG32:out.png
and this converts the PDF to out1.png, out2.png etc.

With node-magickwand I at least managed to get the first page like

let im = new Magick.Image(null);
await im.readAsync('in.pdf');
await im.magickAsync('PNG32');
const blob = new Magick.Blob();
await im.writeAsync(blob);
await writeFile('out.png', blob.data());

But how would I load the PDF with a density of e.g. 150 and save all pages with node-magickwand?

Failed to build on macOS 14 arm64

❯ npm install node-magickwand
npm ERR! code 1
npm ERR! path /Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build && node scripts/gen-es6.js lib/index.mjs
npm ERR! Failed to execute '/opt/homebrew/Cellar/node@18/18.17.1/bin/node /opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64/node-magickwand.node --module_name=node-magickwand --module_path=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64 --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64/node-magickwand.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/mmomtchev/node-magickwand/releases/download/v0.9.7/darwin-arm64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/mmomtchev/node-magickwand/releases/download/v0.9.7/darwin-arm64.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v108 ABI, unknown) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/mmomtchev/node-magickwand/releases/download/v0.9.7/darwin-arm64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/[email protected]/bin/python3.11"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.11
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/jackmatthews/Library/Caches/node-gyp/18.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/jackmatthews/Library/Caches/node-gyp/18.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/jackmatthews/Library/Caches/node-gyp/18.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/pycparser-2.21.dist-info due to invalid metadata entry 'name'
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/cffi-1.16.0.dist-info due to invalid metadata entry 'name'
npm ERR! DEPRECATION: Loading egg at /opt/homebrew/lib/python3.11/site-packages/mtkclient-1.6.3-py3.11.egg is deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use pip for package installation..
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/pycparser-2.21.dist-info due to invalid metadata entry 'name'
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/cffi-1.16.0.dist-info due to invalid metadata entry 'name'
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/pycparser-2.21.dist-info due to invalid metadata entry 'name'
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/cffi-1.16.0.dist-info due to invalid metadata entry 'name'
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/pycparser-2.21.dist-info due to invalid metadata entry 'name'
npm ERR! WARNING: Skipping /opt/homebrew/lib/python3.11/site-packages/cffi-1.16.0.dist-info due to invalid metadata entry 'name'
npm ERR! 
npm ERR! [notice] A new release of pip is available: 23.2.1 -> 23.3
npm ERR! [notice] To update, run: python3.11 -m pip install --upgrade pip
npm ERR! WARN: openexr/3.1.5: requirement zlib/[>=1.2.11 <2] overridden by your conanfile to zlib/1.2.13 
npm ERR! WARN: freetype/2.13.0: requirement libpng/1.6.40 overridden by fontconfig/2.14.2 to libpng/1.6.39 
npm ERR! WARN: freetype/2.13.0: requirement zlib/[>=1.2.10 <2] overridden by fontconfig/2.14.2 to zlib/1.2.13 
npm ERR! WARN: freetype/2.13.0: requirement brotli/1.1.0 overridden by fontconfig/2.14.2 to brotli/1.0.9 
npm ERR! WARN: libpng/1.6.39: requirement zlib/[>=1.2.11 <2] overridden by freetype/2.13.0 to zlib/1.2.13 
npm ERR! WARN: glib/2.78.0: requirement zlib/[>=1.2.11 <2] overridden by your conanfile to zlib/1.2.13 
npm ERR! WARN: pcre2/10.42: requirement zlib/[>=1.2.11 <2] overridden by glib/2.78.0 to zlib/1.2.13 
npm ERR! WARN: harfbuzz/7.1.0: requirement glib/2.77.0 overridden by your conanfile to glib/2.78.0 
npm ERR! WARN: libheif/1.13.0: requirement libde265/1.0.12 overridden by your conanfile to libde265/1.0.11 
npm ERR! WARN: libraw/0.21.1: requirement libjpeg-turbo/2.1.5 overridden by your conanfile to libjpeg-turbo/3.0.0 
npm ERR! WARN: libtiff/4.6.0: requirement zlib/[>=1.2.11 <2] overridden by your conanfile to zlib/1.2.13 
npm ERR! WARN: libxml2/2.10.4: requirement zlib/[>=1.2.11 <2] overridden by your conanfile to zlib/1.2.13 
npm ERR! WARN: libzip/1.9.2: requirement zlib/[>=1.2.11 <2] overridden by your conanfile to zlib/1.2.13 
npm ERR! WARN: libzip/1.9.2: requirement xz_utils/5.4.2 overridden by your conanfile to xz_utils/5.4.4 
npm ERR! WARN: openssl/3.1.3: requirement zlib/[>=1.2.11 <2] overridden by libzip/1.9.2 to zlib/1.2.13 
npm ERR! harfbuzz/7.1.0: WARN: Package binary is corrupted, removing: 4b6a6193d24485c01c73fda8ce1844d971a9fd4b
npm ERR! WARN: pcre2/10.42: requirement zlib/[>=1.2.11 <2] overridden by glib/2.78.0 to zlib/1.2.13 
npm ERR! CMake Deprecation Warning at CMakeLists.txt:10 (cmake_minimum_required):
npm ERR!   Compatibility with CMake < 3.5 will be removed from a future version of
npm ERR!   CMake.
npm ERR! 
npm ERR!   Update the VERSION argument <min> value or use a ...<max> suffix to tell
npm ERR!   CMake that the project does not need compatibility with older versions.
npm ERR! 
npm ERR! 
npm ERR! harfbuzz/7.1.0: WARN: Build folder is dirty, removing it: /Users/jackmatthews/.conan/data/harfbuzz/7.1.0/_/_/build/4b6a6193d24485c01c73fda8ce1844d971a9fd4b
npm ERR! harfbuzz/7.1.0: ERROR: Package '4b6a6193d24485c01c73fda8ce1844d971a9fd4b' build failed
npm ERR! harfbuzz/7.1.0: WARN: Build folder /Users/jackmatthews/.conan/data/harfbuzz/7.1.0/_/_/build/4b6a6193d24485c01c73fda8ce1844d971a9fd4b/build-release
npm ERR! ERROR: harfbuzz/7.1.0: Error in build() method, line 161
npm ERR!        meson.configure()
npm ERR!        ConanException: Error 1 while executing meson setup --native-file "/Users/jackmatthews/.conan/data/harfbuzz/7.1.0/_/_/build/4b6a6193d24485c01c73fda8ce1844d971a9fd4b/build-release/conan/conan_meson_native.ini" "/Users/jackmatthews/.conan/data/harfbuzz/7.1.0/_/_/build/4b6a6193d24485c01c73fda8ce1844d971a9fd4b/build-release" "/Users/jackmatthews/.conan/data/harfbuzz/7.1.0/_/_/build/4b6a6193d24485c01c73fda8ce1844d971a9fd4b/src" -Dprefix="/Users/jackmatthews/.conan/data/harfbuzz/7.1.0/_/_/package/4b6a6193d24485c01c73fda8ce1844d971a9fd4b"
npm ERR! gyp: Call to '(pip3 install --user "conan<2.0.0" && cd build && python3 -m conans.conan install .. -pr:b=default -of build --build=missing --build=openjpeg) > /dev/null' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:325:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 23.0.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node@18/18.17.1/bin/node" "/opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64/node-magickwand.node" "--module_name=node-magickwand" "--module_path=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
npm ERR! gyp ERR! cwd /Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand
npm ERR! gyp ERR! node -v v18.17.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/opt/homebrew/Cellar/node@18/18.17.1/bin/node /opt/homebrew/Cellar/node@18/18.17.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64/node-magickwand.node --module_name=node-magickwand --module_path=/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand/lib/binding/darwin-arm64 --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Darwin 23.0.0
npm ERR! node-pre-gyp ERR! command "/opt/homebrew/Cellar/node@18/18.17.1/bin/node" "/Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/jackmatthews/Projects/DecorProject/decor-server/node_modules/node-magickwand
npm ERR! node-pre-gyp ERR! node -v v18.17.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/jackmatthews/.npm/_logs/2023-10-18T04_48_25_721Z-debug-0.log

Looks like an issue with harfbuzz? Wasn't able to determine the issue in harfbuzz though.

How to set method

Hello is there an equivalent to setting webp:method=0? I can't find it.

Composite transparent images

Hi there,

I just found out about your library! Many thanks for putting this together. It looks great!

I was trying to experiment a bit with overlaying multiple images together. I want to achieve a similar "alpha blend" style as photoshop, where you can overlay multiple transparent images on top of the other. I used your example and it got me here, but this is multiplying, which I don't want and also I haven't figured out how to save the resulting image, to the disk.

Any help would be more than appreciated!

var mw = require('node-magickwand');

const test = async () => {
    let im1 = new mw.Magick.Image("image1.png");
    let im2 = new mw.Magick.Image("image2.png");
    
    await im1.compositeAsync(im2, '0x0+0+0', mw.MagickCore.MultiplyCompositeOp);
    
    const blob = new mw.Magick.Blob;
    await im1.writeAsync(blob);
    const b64 = await blob.base64Async();
    console.log(b64);
}
test()

Rebuilding when installing on macOS/Linux from npm is broken on 0.9.2

npm install node-magickwand --build-from-source fails with:

In file included from ../deps/ImageMagick/Magick++/lib/Magick++/Include.h:16,
                 from ../deps/ImageMagick/Magick++/lib/Magick++.h:12,
                 from ../swig/Magick++.cxx:1981:
../deps/ImageMagick/MagickCore/magick-config.h:25:10: fatal error: MagickCore/magick-baseconfig.h: No such file or directory
   25 | #include "MagickCore/magick-baseconfig.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.